當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Cache::update方法代碼示例

本文整理匯總了PHP中OC\Files\Cache\Cache::update方法的典型用法代碼示例。如果您正苦於以下問題:PHP Cache::update方法的具體用法?PHP Cache::update怎麽用?PHP Cache::update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OC\Files\Cache\Cache的用法示例。


在下文中一共展示了Cache::update方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: scanChildren

 /**
  * scan all the files and folders in a folder
  *
  * @param string $path
  * @param bool $recursive
  * @param int $reuse
  * @param int $folderId id for the folder to be scanned
  * @param bool $lock set to false to disable getting an additional read lock during scanning
  * @return int the size of the scanned folder or -1 if the size is unknown at this stage
  */
 protected function scanChildren($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $folderId = null, $lock = true)
 {
     if ($reuse === -1) {
         $reuse = $recursive === self::SCAN_SHALLOW ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG;
     }
     $this->emit('\\OC\\Files\\Cache\\Scanner', 'scanFolder', array($path, $this->storageId));
     $size = 0;
     if (!is_null($folderId)) {
         $folderId = $this->cache->getId($path);
     }
     $childQueue = $this->handleChildren($path, $recursive, $reuse, $folderId, $lock, $size);
     foreach ($childQueue as $child => $childId) {
         $childSize = $this->scanChildren($child, $recursive, $reuse, $childId, $lock);
         if ($childSize === -1) {
             $size = -1;
         } else {
             if ($size !== -1) {
                 $size += $childSize;
             }
         }
     }
     if ($this->cacheActive) {
         $this->cache->update($folderId, array('size' => $size));
     }
     $this->emit('\\OC\\Files\\Cache\\Scanner', 'postScanFolder', array($path, $this->storageId));
     return $size;
 }
開發者ID:GitHubUser4234,項目名稱:core,代碼行數:37,代碼來源:Scanner.php

示例2: correctParentStorageMtime

 /**
  * update the storage_mtime of the direct parent in the cache to the mtime from the storage
  *
  * @param string $internalPath
  */
 private function correctParentStorageMtime($internalPath)
 {
     $parentId = $this->cache->getParentId($internalPath);
     $parent = dirname($internalPath);
     if ($parentId != -1) {
         $this->cache->update($parentId, array('storage_mtime' => $this->storage->filemtime($parent)));
     }
 }
開發者ID:farukuzun,項目名稱:core-1,代碼行數:13,代碼來源:updater.php

示例3: updateCache

	/**
	 * @param string $path
	 * @param array $data
	 * @param int $fileId
	 */
	protected function updateCache($path, $data, $fileId = -1) {
		\OC_Hook::emit('Scanner', 'addToCache', array('file' => $path, 'data' => $data));
		$this->emit('\OC\Files\Cache\Scanner', 'updateCache', array($path, $this->storageId, $data));
		if ($this->cacheActive) {
			if ($fileId !== -1) {
				$this->cache->update($fileId, $data);
			} else {
				$this->cache->put($path, $data);
			}
		}
	}
開發者ID:ninjasilicon,項目名稱:core,代碼行數:16,代碼來源:scanner.php

示例4: scanFile

 /**
  * scan a single file and store it in the cache
  *
  * @param string $file
  * @param int $reuseExisting
  * @param bool $parentExistsInCache
  * @return array with metadata of the scanned file
  */
 public function scanFile($file, $reuseExisting = 0, $parentExistsInCache = false)
 {
     if (!self::isPartialFile($file) and !Filesystem::isFileBlacklisted($file)) {
         $this->emit('\\OC\\Files\\Cache\\Scanner', 'scanFile', array($file, $this->storageId));
         \OC_Hook::emit('\\OC\\Files\\Cache\\Scanner', 'scan_file', array('path' => $file, 'storage' => $this->storageId));
         $data = $this->getData($file);
         if ($data) {
             if ($file and !$parentExistsInCache) {
                 $parent = dirname($file);
                 if ($parent === '.' or $parent === '/') {
                     $parent = '';
                 }
                 if (!$this->cache->inCache($parent)) {
                     $this->scanFile($parent);
                 }
             }
             $newData = $data;
             $cacheData = $this->cache->get($file);
             if ($cacheData) {
                 if (isset($cacheData['fileid'])) {
                     $this->permissionsCache->remove($cacheData['fileid']);
                 }
                 if ($reuseExisting) {
                     // prevent empty etag
                     $etag = $cacheData['etag'];
                     $propagateETagChange = false;
                     if (empty($etag)) {
                         $etag = $data['etag'];
                         $propagateETagChange = true;
                     }
                     // only reuse data if the file hasn't explicitly changed
                     if (isset($data['mtime']) && isset($cacheData['mtime']) && $data['mtime'] === $cacheData['mtime']) {
                         if ($reuseExisting & self::REUSE_SIZE && $data['size'] === -1) {
                             $data['size'] = $cacheData['size'];
                         }
                         if ($reuseExisting & self::REUSE_ETAG) {
                             $data['etag'] = $etag;
                             if ($propagateETagChange) {
                                 $parent = $file;
                                 while ($parent !== '') {
                                     $parent = dirname($parent);
                                     if ($parent === '.') {
                                         $parent = '';
                                     }
                                     $parentCacheData = $this->cache->get($parent);
                                     $this->cache->update($parentCacheData['fileid'], array('etag' => $this->storage->getETag($parent)));
                                 }
                             }
                         }
                     }
                     // Only update metadata that has changed
                     $newData = array_diff_assoc($data, $cacheData);
                     if (isset($newData['etag'])) {
                         $cacheDataString = print_r($cacheData, true);
                         $dataString = print_r($data, true);
                         \OCP\Util::writeLog('OC\\Files\\Cache\\Scanner', "!!! No reuse of etag for '{$file}' !!! \ncache: {$cacheDataString} \ndata: {$dataString}", \OCP\Util::DEBUG);
                     }
                 }
             }
             if (!empty($newData)) {
                 $this->cache->put($file, $newData);
                 $this->emit('\\OC\\Files\\Cache\\Scanner', 'postScanFile', array($file, $this->storageId));
                 \OC_Hook::emit('\\OC\\Files\\Cache\\Scanner', 'post_scan_file', array('path' => $file, 'storage' => $this->storageId));
             }
         } else {
             $this->cache->remove($file);
         }
         return $data;
     }
     return null;
 }
開發者ID:omusico,項目名稱:isle-web-framework,代碼行數:79,代碼來源:scanner.php

示例5: update

 /**
  * update the metadata in the cache
  *
  * @param int $id
  * @param array $data
  */
 public function update($id, array $data)
 {
     $this->cache->update($id, $data);
 }
開發者ID:kebenxiaoming,項目名稱:owncloudRedis,代碼行數:10,代碼來源:cachewrapper.php


注:本文中的OC\Files\Cache\Cache::update方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。