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


PHP Cache::get方法代码示例

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


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

示例1: get

 /**
  * get the stored metadata of a file or folder
  *
  * @param string /int $file
  * @return array|false
  */
 public function get($file)
 {
     $result = $this->cache->get($file);
     if ($result) {
         $result = $this->formatCacheEntry($result);
     }
     return $result;
 }
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:14,代码来源:cachewrapper.php

示例2: checkUpdate

 /**
  * check $path for updates and update if needed
  *
  * @param string $path
  * @param ICacheEntry|null $cachedEntry
  * @return boolean true if path was updated
  */
 public function checkUpdate($path, $cachedEntry = null)
 {
     if (is_null($cachedEntry)) {
         $cachedEntry = $this->cache->get($path);
     }
     if ($this->needsUpdate($path, $cachedEntry)) {
         $this->update($path, $cachedEntry);
         return true;
     } else {
         return false;
     }
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:19,代码来源:Watcher.php

示例3: scanFile

 /**
  * scan a single file and store it in the cache
  *
  * @param string $file
  * @param int $reuseExisting
  * @return array an array of metadata of the scanned file
  */
 public function scanFile($file, $reuseExisting = 0)
 {
     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) {
             $parent = dirname($file);
             if ($parent === '.' or $parent === '/') {
                 $parent = '';
             }
             $parentId = $this->cache->getId($parent);
             // scan the parent if it's not in the cache (id -1) and the current file is not the root folder
             if ($file and $parentId === -1) {
                 $parentData = $this->scanFile($parent);
                 $parentId = $parentData['fileid'];
             }
             if ($parent) {
                 $data['parent'] = $parentId;
             }
             $cacheData = $this->cache->get($file);
             if ($cacheData and $reuseExisting) {
                 // prevent empty etag
                 if (empty($cacheData['etag'])) {
                     $etag = $data['etag'];
                 } else {
                     $etag = $cacheData['etag'];
                 }
                 // only reuse data if the file hasn't explicitly changed
                 if (isset($data['storage_mtime']) && isset($cacheData['storage_mtime']) && $data['storage_mtime'] === $cacheData['storage_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;
                     }
                 }
                 // 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);
                 }
             } else {
                 $newData = $data;
             }
             if (!empty($newData)) {
                 $data['fileid'] = $this->addToCache($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->removeFromCache($file);
         }
         return $data;
     }
     return null;
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:67,代码来源:scanner.php

示例4: testWithNormalizer

 /**
  * this test shows that there is no bug if we use the normalizer
  */
 public function testWithNormalizer()
 {
     if (!class_exists('Patchwork\\PHP\\Shim\\Normalizer')) {
         $this->markTestSkipped('The 3rdparty Normalizer extension is not available.');
         return;
     }
     // folder name "Schön" with U+00F6 (normalized)
     $folderWith00F6 = "Schön";
     // folder name "Schön" with U+0308 (un-normalized)
     $folderWith0308 = "Schön";
     $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory');
     // put root folder
     $this->assertFalse($this->cache->get('folder'));
     $this->assertGreaterThan(0, $this->cache->put('folder', $data));
     // put un-normalized folder
     $this->assertFalse($this->cache->get('folder/' . $folderWith0308));
     $this->assertGreaterThan(0, $this->cache->put('folder/' . $folderWith0308, $data));
     // get un-normalized folder by name
     $unNormalizedFolderName = $this->cache->get('folder/' . $folderWith0308);
     // check if folder name was normalized
     $this->assertEquals($folderWith00F6, $unNormalizedFolderName['name']);
     // put normalized folder
     $this->assertTrue(is_array($this->cache->get('folder/' . $folderWith00F6)));
     $this->assertGreaterThan(0, $this->cache->put('folder/' . $folderWith00F6, $data));
     // at this point we should have only one folder named "Schön"
     $this->assertEquals(1, count($this->cache->getFolderContents('folder')));
 }
开发者ID:Romua1d,项目名称:core,代码行数:30,代码来源:cache.php

示例5: testTouch

 public function testTouch()
 {
     $rootCachedData = $this->cache->get('');
     $fooCachedData = $this->cache->get('foo.txt');
     Filesystem::touch('foo.txt');
     $cachedData = $this->cache->get('foo.txt');
     $this->assertInternalType('string', $fooCachedData['etag']);
     $this->assertInternalType('string', $cachedData['etag']);
     $this->assertGreaterThanOrEqual($fooCachedData['mtime'], $cachedData['mtime']);
     $cachedData = $this->cache->get('');
     $this->assertInternalType('string', $rootCachedData['etag']);
     $this->assertInternalType('string', $cachedData['etag']);
     $this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
     $this->assertGreaterThanOrEqual($rootCachedData['mtime'], $cachedData['mtime']);
     $rootCachedData = $cachedData;
     $time = 1371006070;
     $barCachedData = $this->cache->get('folder/bar.txt');
     $folderCachedData = $this->cache->get('folder');
     $this->cache->put('', ['mtime' => $time - 100]);
     Filesystem::touch('folder/bar.txt', $time);
     $cachedData = $this->cache->get('folder/bar.txt');
     $this->assertInternalType('string', $barCachedData['etag']);
     $this->assertInternalType('string', $cachedData['etag']);
     $this->assertNotSame($barCachedData['etag'], $cachedData['etag']);
     $this->assertEquals($time, $cachedData['mtime']);
     $cachedData = $this->cache->get('folder');
     $this->assertInternalType('string', $folderCachedData['etag']);
     $this->assertInternalType('string', $cachedData['etag']);
     $this->assertNotSame($folderCachedData['etag'], $cachedData['etag']);
     $cachedData = $this->cache->get('');
     $this->assertInternalType('string', $rootCachedData['etag']);
     $this->assertInternalType('string', $cachedData['etag']);
     $this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
     $this->assertEquals($time, $cachedData['mtime']);
 }
开发者ID:kebenxiaoming,项目名称:core,代码行数:35,代码来源:updaterlegacy.php

示例6: testTouchWithMountPoints

	public function testTouchWithMountPoints() {
		$storage2 = new \OC\Files\Storage\Temporary(array());
		$cache2 = $storage2->getCache();
		Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage');
		Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd');
		$this->assertTrue($cache2->inCache('foo.txt'));
		$folderCachedData = $this->cache->get('folder');
		$substorageCachedData = $cache2->get('');
		$fooCachedData = $cache2->get('foo.txt');
		$cachedData = $cache2->get('foo.txt');
		$time = 1371006070;
		$this->cache->put('folder', ['mtime' => $time - 100]);
		Filesystem::touch('folder/substorage/foo.txt', $time);
		$cachedData = $cache2->get('foo.txt');
		$this->assertInternalType('string', $fooCachedData['etag']);
		$this->assertInternalType('string', $cachedData['etag']);
		$this->assertNotSame($fooCachedData['etag'], $cachedData['etag']);
		$this->assertEquals($time, $cachedData['mtime']);

		$cachedData = $cache2->get('');
		$this->assertInternalType('string', $substorageCachedData['etag']);
		$this->assertInternalType('string', $cachedData['etag']);
		$this->assertNotSame($substorageCachedData['etag'], $cachedData['etag']);

		$cachedData = $this->cache->get('folder');
		$this->assertInternalType('string', $folderCachedData['etag']);
		$this->assertInternalType('string', $cachedData['etag']);
		$this->assertNotSame($folderCachedData['etag'], $cachedData['etag']);
		$this->assertEquals($time, $cachedData['mtime']);
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:30,代码来源:updaterlegacy.php

示例7: get

 public function get($file)
 {
     $result = parent::get($file);
     $result['displayname_owner'] = $this->remoteUser . '@' . $this->remote;
     if (!$file || $file === '') {
         $result['is_share_mount_point'] = true;
         $mountPoint = rtrim($this->storage->getMountPoint());
         $result['name'] = basename($mountPoint);
     }
     return $result;
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:11,代码来源:cache.php

示例8: 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

示例9: getOwnerDirSizes

 /**
  * Returns the sizes of the path and its parent dirs in a hash
  * where the key is the path and the value is the size.
  * @param string $path
  */
 function getOwnerDirSizes($path)
 {
     $result = array();
     while ($path != '' && $path != '' && $path != '.') {
         $cachedData = $this->ownerCache->get($path);
         $result[$path] = $cachedData['size'];
         $path = dirname($path);
     }
     $cachedData = $this->ownerCache->get('');
     $result[''] = $cachedData['size'];
     return $result;
 }
开发者ID:Romua1d,项目名称:core,代码行数:17,代码来源:watcher.php

示例10: get

 /**
  * @param string $path
  * @return ICacheEntry
  */
 public function get($path)
 {
     $data = parent::get($path);
     if ($path === '' or $path === '/') {
         // only the size of the "files" dir counts
         $filesData = parent::get('files');
         if (isset($filesData['size'])) {
             $data['size'] = $filesData['size'];
         }
     }
     return $data;
 }
开发者ID:kenwi,项目名称:core,代码行数:16,代码来源:homecache.php

示例11: testNoReuseOfFileId

	public function testNoReuseOfFileId() {
		$data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain');
		$this->cache->put('somefile.txt', $data1);
		$info = $this->cache->get('somefile.txt');
		$fileId = $info['fileid'];
		$this->cache->remove('somefile.txt');
		$data2 = array('size' => 200, 'mtime' => 100, 'mimetype' => 'text/plain');
		$this->cache->put('anotherfile.txt', $data2);
		$info2 = $this->cache->get('anotherfile.txt');
		$fileId2 = $info2['fileid'];
		$this->assertNotEquals($fileId, $fileId2);
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:12,代码来源:cache.php

示例12: 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

示例13: testSearchByTagTree

 /**
  * Test searching by tag for multiple sections of the tree
  */
 function testSearchByTagTree()
 {
     $userId = \OC::$server->getUserSession()->getUser()->getUId();
     $this->sharedStorage->mkdir('subdir/emptydir');
     $this->sharedStorage->mkdir('subdir/emptydir2');
     $this->ownerStorage->getScanner()->scan('');
     $allIds = array($this->sharedCache->get('')['fileid'], $this->sharedCache->get('bar.txt')['fileid'], $this->sharedCache->get('subdir/another too.txt')['fileid'], $this->sharedCache->get('subdir/not a text file.xml')['fileid'], $this->sharedCache->get('subdir/another.txt')['fileid'], $this->sharedCache->get('subdir/emptydir')['fileid'], $this->sharedCache->get('subdir/emptydir2')['fileid']);
     $tagManager = \OC::$server->getTagManager()->load('files', null, null, $userId);
     foreach ($allIds as $id) {
         $tagManager->tagAs($id, 'tag1');
     }
     $results = $this->sharedStorage->getCache()->searchByTag('tag1', $userId);
     $check = array(array('name' => 'shareddir', 'path' => ''), array('name' => 'bar.txt', 'path' => 'bar.txt'), array('name' => 'another.txt', 'path' => 'subdir/another.txt'), array('name' => 'another too.txt', 'path' => 'subdir/another too.txt'), array('name' => 'emptydir', 'path' => 'subdir/emptydir'), array('name' => 'emptydir2', 'path' => 'subdir/emptydir2'), array('name' => 'not a text file.xml', 'path' => 'subdir/not a text file.xml'));
     $this->verifyFiles($check, $results);
     $tagManager->delete(array('tag1'));
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:19,代码来源:cache.php

示例14: testBogusPaths

 /**
  * Test bogus paths with leading or doubled slashes
  *
  * @dataProvider bogusPathNamesProvider
  */
 public function testBogusPaths($bogusPath, $fixedBogusPath)
 {
     $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory');
     // put root folder
     $this->assertFalse($this->cache->get(''));
     $parentId = $this->cache->put('', $data);
     $this->assertGreaterThan(0, $parentId);
     $this->assertGreaterThan(0, $this->cache->put($bogusPath, $data));
     $newData = $this->cache->get($fixedBogusPath);
     $this->assertNotFalse($newData);
     $this->assertEquals($fixedBogusPath, $newData['path']);
     // parent is the correct one, resolved properly (they used to not be)
     $this->assertEquals($parentId, $newData['parent']);
     $newDataFromBogus = $this->cache->get($bogusPath);
     // same entry
     $this->assertEquals($newData, $newDataFromBogus);
 }
开发者ID:riso,项目名称:owncloud-core,代码行数:22,代码来源:cache.php

示例15: 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


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