当前位置: 首页>>代码示例>>PHP>>正文


PHP Cache::inCache方法代码示例

本文整理汇总了PHP中OC\Files\Cache\Cache::inCache方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::inCache方法的具体用法?PHP Cache::inCache怎么用?PHP Cache::inCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OC\Files\Cache\Cache的用法示例。


在下文中一共展示了Cache::inCache方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testClearKeepEntriesOutsideJail

 function testClearKeepEntriesOutsideJail()
 {
     $file1 = 'foo/foobar';
     $file2 = 'foo/foobar/asd';
     $file3 = 'folder/foobar';
     $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory');
     $this->sourceCache->put('foo', $data1);
     $this->sourceCache->put($file1, $data1);
     $this->sourceCache->put($file2, $data1);
     $this->sourceCache->put($file3, $data1);
     $this->cache->clear();
     $this->assertFalse($this->cache->inCache('foobar'));
     $this->assertTrue($this->sourceCache->inCache('folder/foobar'));
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:14,代码来源:CacheJailTest.php

示例2: renameFromStorage

 /**
  * Rename a file or folder in the cache and update the size, etag and mtime of the parent folders
  *
  * @param IStorage $sourceStorage
  * @param string $source
  * @param string $target
  */
 public function renameFromStorage(IStorage $sourceStorage, $source, $target)
 {
     if (!$this->enabled or Scanner::isPartialFile($source) or Scanner::isPartialFile($target)) {
         return;
     }
     $time = time();
     $sourceCache = $sourceStorage->getCache();
     $sourceUpdater = $sourceStorage->getUpdater();
     $sourcePropagator = $sourceStorage->getPropagator();
     if ($sourceCache->inCache($source)) {
         if ($this->cache->inCache($target)) {
             $this->cache->remove($target);
         }
         if ($sourceStorage === $this->storage) {
             $this->cache->move($source, $target);
         } else {
             $this->cache->moveFromCache($sourceCache, $source, $target);
         }
     }
     if (pathinfo($source, PATHINFO_EXTENSION) !== pathinfo($target, PATHINFO_EXTENSION)) {
         // handle mime type change
         $mimeType = $this->storage->getMimeType($target);
         $fileId = $this->cache->getId($target);
         $this->cache->update($fileId, ['mimetype' => $mimeType]);
     }
     $sourceCache->correctFolderSize($source);
     $this->cache->correctFolderSize($target);
     if ($sourceUpdater instanceof Updater) {
         $sourceUpdater->correctParentStorageMtime($source);
     }
     $this->correctParentStorageMtime($target);
     $this->updateStorageMTimeOnly($target);
     $sourcePropagator->propagateChange($source, $time);
     $this->propagator->propagateChange($target, $time);
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:42,代码来源:updater.php

示例3: getExistingChildren

 protected function getExistingChildren($path)
 {
     $existingChildren = array();
     if ($this->cache->inCache($path)) {
         $children = $this->cache->getFolderContents($path);
         foreach ($children as $child) {
             $existingChildren[] = $child['name'];
         }
     }
     return $existingChildren;
 }
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:11,代码来源:scanner.php

示例4: testMoveFolderCrossStorage

	public function testMoveFolderCrossStorage() {
		$storage2 = new Temporary(array());
		$cache2 = $storage2->getCache();
		Filesystem::mount($storage2, array(), '/bar');
		$this->storage->mkdir('foo');
		$this->storage->mkdir('foo/bar');
		$this->storage->file_put_contents('foo/foo.txt', 'qwerty');
		$this->storage->file_put_contents('foo/bar.txt', 'foo');
		$this->storage->file_put_contents('foo/bar/bar.txt', 'qwertyuiop');

		$this->storage->getScanner()->scan('');

		$this->assertTrue($this->cache->inCache('foo'));
		$this->assertTrue($this->cache->inCache('foo/foo.txt'));
		$this->assertTrue($this->cache->inCache('foo/bar.txt'));
		$this->assertTrue($this->cache->inCache('foo/bar'));
		$this->assertTrue($this->cache->inCache('foo/bar/bar.txt'));
		$cached = [];
		$cached[] = $this->cache->get('foo');
		$cached[] = $this->cache->get('foo/foo.txt');
		$cached[] = $this->cache->get('foo/bar.txt');
		$cached[] = $this->cache->get('foo/bar');
		$cached[] = $this->cache->get('foo/bar/bar.txt');

		// add extension to trigger the possible mimetype change
		$this->view->rename('/foo', '/bar/foo.b');

		$this->assertFalse($this->cache->inCache('foo'));
		$this->assertFalse($this->cache->inCache('foo/foo.txt'));
		$this->assertFalse($this->cache->inCache('foo/bar.txt'));
		$this->assertFalse($this->cache->inCache('foo/bar'));
		$this->assertFalse($this->cache->inCache('foo/bar/bar.txt'));
		$this->assertTrue($cache2->inCache('foo.b'));
		$this->assertTrue($cache2->inCache('foo.b/foo.txt'));
		$this->assertTrue($cache2->inCache('foo.b/bar.txt'));
		$this->assertTrue($cache2->inCache('foo.b/bar'));
		$this->assertTrue($cache2->inCache('foo.b/bar/bar.txt'));

		$cachedTarget = [];
		$cachedTarget[] = $cache2->get('foo.b');
		$cachedTarget[] = $cache2->get('foo.b/foo.txt');
		$cachedTarget[] = $cache2->get('foo.b/bar.txt');
		$cachedTarget[] = $cache2->get('foo.b/bar');
		$cachedTarget[] = $cache2->get('foo.b/bar/bar.txt');

		foreach ($cached as $i => $old) {
			$new = $cachedTarget[$i];
			$this->assertEquals($old['mtime'], $new['mtime']);
			$this->assertEquals($old['size'], $new['size']);
			$this->assertEquals($old['etag'], $new['etag']);
			$this->assertEquals($old['fileid'], $new['fileid']);
			$this->assertEquals($old['mimetype'], $new['mimetype']);
		}
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:54,代码来源:updater.php

示例5: testMoveDisabled

 public function testMoveDisabled()
 {
     $this->storage->file_put_contents('foo.txt', 'qwerty');
     $this->updater->update('foo.txt');
     $this->assertTrue($this->cache->inCache('foo.txt'));
     $this->assertFalse($this->cache->inCache('bar.txt'));
     $cached = $this->cache->get('foo.txt');
     $this->storage->rename('foo.txt', 'bar.txt');
     $this->assertTrue($this->cache->inCache('foo.txt'));
     $this->assertFalse($this->cache->inCache('bar.txt'));
     $this->updater->disable();
     $this->updater->rename('foo.txt', 'bar.txt');
     $this->assertTrue($this->cache->inCache('foo.txt'));
     $this->assertFalse($this->cache->inCache('bar.txt'));
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:15,代码来源:updater.php

示例6: backgroundScan

 /**
  * walk over any folders that are not fully scanned yet and scan them
  */
 public function backgroundScan()
 {
     if (!$this->cache->inCache('')) {
         $this->runBackgroundScanJob(function () {
             $this->scan('', self::SCAN_RECURSIVE, self::REUSE_ETAG);
         }, '');
     } else {
         $lastPath = null;
         while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) {
             $this->runBackgroundScanJob(function () use($path) {
                 $this->scan($path, self::SCAN_RECURSIVE, self::REUSE_ETAG);
             }, $path);
             // FIXME: this won't proceed with the next item, needs revamping of getIncomplete()
             // to make this possible
             $lastPath = $path;
         }
     }
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:21,代码来源:Scanner.php

示例7: testRepairParentShallow

 public function testRepairParentShallow()
 {
     $this->fillTestFolders();
     $this->scanner->scan('');
     $this->assertTrue($this->cache->inCache('folder/bar.txt'));
     $oldFolderId = $this->cache->getId('folder');
     // delete the folder without removing the childs
     $sql = 'DELETE FROM `*PREFIX*filecache` WHERE `fileid` = ?';
     \OC_DB::executeAudited($sql, array($oldFolderId));
     $cachedData = $this->cache->get('folder/bar.txt');
     $this->assertEquals($oldFolderId, $cachedData['parent']);
     $this->assertFalse($this->cache->inCache('folder'));
     $this->scanner->scan('folder', \OC\Files\Cache\Scanner::SCAN_SHALLOW);
     $this->assertTrue($this->cache->inCache('folder'));
     $newFolderId = $this->cache->getId('folder');
     $this->assertNotEquals($oldFolderId, $newFolderId);
     $cachedData = $this->cache->get('folder/bar.txt');
     $this->assertEquals($newFolderId, $cachedData['parent']);
 }
开发者ID:0x17de,项目名称:core,代码行数:19,代码来源:scanner.php

示例8: testMove

	function testMove() {
		$file1 = 'folder';
		$file2 = 'folder/bar';
		$file3 = 'folder/foo';
		$file4 = 'folder/foo/1';
		$file5 = 'folder/foo/2';
		$data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/bar');
		$folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory');

		$this->cache->put($file1, $folderData);
		$this->cache->put($file2, $folderData);
		$this->cache->put($file3, $folderData);
		$this->cache->put($file4, $data);
		$this->cache->put($file5, $data);

		/* simulate a second user with a different storage id but the same folder structure */
		$this->cache2->put($file1, $folderData);
		$this->cache2->put($file2, $folderData);
		$this->cache2->put($file3, $folderData);
		$this->cache2->put($file4, $data);
		$this->cache2->put($file5, $data);

		$this->cache->move('folder/foo', 'folder/foobar');

		$this->assertFalse($this->cache->inCache('folder/foo'));
		$this->assertFalse($this->cache->inCache('folder/foo/1'));
		$this->assertFalse($this->cache->inCache('folder/foo/2'));

		$this->assertTrue($this->cache->inCache('folder/bar'));
		$this->assertTrue($this->cache->inCache('folder/foobar'));
		$this->assertTrue($this->cache->inCache('folder/foobar/1'));
		$this->assertTrue($this->cache->inCache('folder/foobar/2'));

		/* the folder structure of the second user must not change! */
		$this->assertTrue($this->cache2->inCache('folder/bar'));
		$this->assertTrue($this->cache2->inCache('folder/foo'));
		$this->assertTrue($this->cache2->inCache('folder/foo/1'));
		$this->assertTrue($this->cache2->inCache('folder/foo/2'));

		$this->assertFalse($this->cache2->inCache('folder/foobar'));
		$this->assertFalse($this->cache2->inCache('folder/foobar/1'));
		$this->assertFalse($this->cache2->inCache('folder/foobar/2'));
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:43,代码来源:cache.php

示例9: testMove

 public function testMove()
 {
     $this->storage->file_put_contents('foo.txt', 'qwerty');
     $this->updater->update('foo.txt');
     $this->assertTrue($this->cache->inCache('foo.txt'));
     $this->assertFalse($this->cache->inCache('bar.txt'));
     $cached = $this->cache->get('foo.txt');
     $this->storage->rename('foo.txt', 'bar.txt');
     $this->assertTrue($this->cache->inCache('foo.txt'));
     $this->assertFalse($this->cache->inCache('bar.txt'));
     $this->updater->rename('foo.txt', 'bar.txt');
     $this->assertFalse($this->cache->inCache('foo.txt'));
     $this->assertTrue($this->cache->inCache('bar.txt'));
     $cachedTarget = $this->cache->get('bar.txt');
     $this->assertEquals($cached['etag'], $cachedTarget['etag']);
     $this->assertEquals($cached['mtime'], $cachedTarget['mtime']);
     $this->assertEquals($cached['size'], $cachedTarget['size']);
     $this->assertEquals($cached['fileid'], $cachedTarget['fileid']);
 }
开发者ID:Combustible,项目名称:core,代码行数:19,代码来源:updater.php

示例10: testRename

 public function testRename()
 {
     $textSize = strlen("dummy file data\n");
     $imageSize = filesize(\OC::$SERVERROOT . '/core/img/logo.png');
     $rootCachedData = $this->cache->get('');
     $this->assertEquals(3 * $textSize + $imageSize, $rootCachedData['size']);
     $this->assertTrue($this->cache->inCache('foo.txt'));
     $fooCachedData = $this->cache->get('foo.txt');
     $this->assertFalse($this->cache->inCache('bar.txt'));
     Filesystem::rename('foo.txt', 'bar.txt');
     $this->assertFalse($this->cache->inCache('foo.txt'));
     $this->assertTrue($this->cache->inCache('bar.txt'));
     $cachedData = $this->cache->get('bar.txt');
     $this->assertEquals($fooCachedData['fileid'], $cachedData['fileid']);
     $mtime = $cachedData['mtime'];
     $cachedData = $this->cache->get('');
     $this->assertEquals(3 * $textSize + $imageSize, $cachedData['size']);
     $this->assertInternalType('string', $rootCachedData['etag']);
     $this->assertInternalType('string', $cachedData['etag']);
     $this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
 }
开发者ID:kebenxiaoming,项目名称:core,代码行数:21,代码来源:updaterlegacy.php

示例11: testEscaping

 /**
  * @param string $name
  * @dataProvider escapingProvider
  */
 public function testEscaping($name)
 {
     $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain');
     $this->cache->put($name, $data);
     $this->assertTrue($this->cache->inCache($name));
     $retrievedData = $this->cache->get($name);
     foreach ($data as $key => $value) {
         $this->assertEquals($value, $retrievedData[$key]);
     }
     $this->cache->move($name, $name . 'asd');
     $this->assertFalse($this->cache->inCache($name));
     $this->assertTrue($this->cache->inCache($name . 'asd'));
     $this->cache->remove($name . 'asd');
     $this->assertFalse($this->cache->inCache($name . 'asd'));
     $folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory');
     $this->cache->put($name, $folderData);
     $this->cache->put('other', $folderData);
     $childs = ['asd', 'bar', 'foo', 'sub/folder'];
     $this->cache->put($name . '/sub', $folderData);
     $this->cache->put('other/sub', $folderData);
     foreach ($childs as $child) {
         $this->cache->put($name . '/' . $child, $data);
         $this->cache->put('other/' . $child, $data);
         $this->assertTrue($this->cache->inCache($name . '/' . $child));
     }
     $this->cache->move($name, $name . 'asd');
     foreach ($childs as $child) {
         $this->assertTrue($this->cache->inCache($name . 'asd/' . $child));
         $this->assertTrue($this->cache->inCache('other/' . $child));
     }
     foreach ($childs as $child) {
         $this->cache->remove($name . 'asd/' . $child);
         $this->assertFalse($this->cache->inCache($name . 'asd/' . $child));
         $this->assertTrue($this->cache->inCache('other/' . $child));
     }
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:40,代码来源:cache.php

示例12: inCache

 /**
  * check if a file is available in the cache
  *
  * @param string $file
  * @return bool
  */
 public function inCache($file)
 {
     if ($file == '') {
         return true;
     }
     return parent::inCache($file);
 }
开发者ID:Combustible,项目名称:core,代码行数:13,代码来源:cache.php

示例13: scanChildren

 /**
  * scan all the files and folders in a folder
  *
  * @param string $path
  * @param bool $recursive
  * @param int $reuse
  * @return int the size of the scanned folder or -1 if the size is unknown at this stage
  */
 public function scanChildren($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1)
 {
     if ($reuse === -1) {
         $reuse = $recursive === self::SCAN_SHALLOW ? self::REUSE_ETAG | self::REUSE_SIZE : 0;
     }
     $this->emit('\\OC\\Files\\Cache\\Scanner', 'scanFolder', array($path, $this->storageId));
     $size = 0;
     $childQueue = array();
     $existingChildren = array();
     if ($this->cache->inCache($path)) {
         $children = $this->cache->getFolderContents($path);
         foreach ($children as $child) {
             $existingChildren[] = $child['name'];
         }
     }
     $newChildren = array();
     if ($this->storage->is_dir($path) && ($dh = $this->storage->opendir($path))) {
         $exceptionOccurred = false;
         \OC_DB::beginTransaction();
         if (is_resource($dh)) {
             while (($file = readdir($dh)) !== false) {
                 $child = $path ? $path . '/' . $file : $file;
                 if (!Filesystem::isIgnoredDir($file)) {
                     $newChildren[] = $file;
                     try {
                         $data = $this->scanFile($child, $reuse, true);
                         if ($data) {
                             if ($data['size'] === -1) {
                                 if ($recursive === self::SCAN_RECURSIVE) {
                                     $childQueue[] = $child;
                                 } else {
                                     $size = -1;
                                 }
                             } else {
                                 if ($size !== -1) {
                                     $size += $data['size'];
                                 }
                             }
                         }
                     } catch (\Doctrine\DBAL\DBALException $ex) {
                         // might happen if inserting duplicate while a scanning
                         // process is running in parallel
                         // log and ignore
                         \OC_Log::write('core', 'Exception while scanning file "' . $child . '": ' . $ex->getMessage(), \OC_Log::DEBUG);
                         $exceptionOccurred = true;
                     }
                 }
             }
         }
         $removedChildren = \array_diff($existingChildren, $newChildren);
         foreach ($removedChildren as $childName) {
             $child = $path ? $path . '/' . $childName : $childName;
             $this->cache->remove($child);
         }
         \OC_DB::commit();
         if ($exceptionOccurred) {
             // It might happen that the parallel scan process has already
             // inserted mimetypes but those weren't available yet inside the transaction
             // To make sure to have the updated mime types in such cases,
             // we reload them here
             $this->cache->loadMimetypes();
         }
         foreach ($childQueue as $child) {
             $childSize = $this->scanChildren($child, self::SCAN_RECURSIVE, $reuse);
             if ($childSize === -1) {
                 $size = -1;
             } else {
                 $size += $childSize;
             }
         }
         $this->cache->put($path, array('size' => $size));
     }
     $this->emit('\\OC\\Files\\Cache\\Scanner', 'postScanFolder', array($path, $this->storageId));
     return $size;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:83,代码来源:scanner.php

示例14: inCache

 /**
  * check if a file is available in the cache
  *
  * @param string $file
  * @return bool
  */
 public function inCache($file)
 {
     return $this->cache->inCache($file);
 }
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:10,代码来源:cachewrapper.php


注:本文中的OC\Files\Cache\Cache::inCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。