当前位置: 首页>>代码示例>>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;未经允许,请勿转载。