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


PHP Cache\Cache类代码示例

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


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

示例1: testGetMasked

 /**
  * @dataProvider maskProvider
  * @param int $mask
  */
 public function testGetMasked($mask)
 {
     $cache = $this->getMaskedCached($mask);
     $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain', 'permissions' => Constants::PERMISSION_ALL);
     $this->sourceCache->put('foo', $data);
     $result = $cache->get('foo');
     $this->assertEquals($mask, $result['permissions']);
     $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain', 'permissions' => Constants::PERMISSION_ALL - Constants::PERMISSION_DELETE);
     $this->sourceCache->put('bar', $data);
     $result = $cache->get('bar');
     $this->assertEquals($mask & ~Constants::PERMISSION_DELETE, $result['permissions']);
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:16,代码来源:CachePermissionsMaskTest.php

示例2: tearDown

 function tearDown()
 {
     $this->sharedCache->clear();
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $fileinfo = $this->view->getFileInfo('container/shareddir');
     \OCP\Share::unshare('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
     $fileinfo = $this->view->getFileInfo('container/shared single file.txt');
     \OCP\Share::unshare('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
     $this->view->deleteAll('container');
     $this->ownerCache->clear();
     parent::tearDown();
 }
开发者ID:droiter,项目名称:openwrt-on-android,代码行数:12,代码来源:cache.php

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

示例4: checkUpdate

 private static function checkUpdate($id)
 {
     $cacheItem = Cache::getById($id);
     if (is_null($cacheItem)) {
         return;
     }
     list($storageId, $internalPath) = $cacheItem;
     $mounts = Filesystem::getMountByStorageId($storageId);
     if (count($mounts) === 0) {
         //if the storage we need isn't mounted on default, try to find a user that has access to the storage
         $permissionsCache = new Permissions($storageId);
         $users = $permissionsCache->getUsers($id);
         if (count($users) === 0) {
             return;
         }
         Filesystem::initMountPoints($users[0]);
         $mounts = Filesystem::getMountByStorageId($storageId);
         if (count($mounts) === 0) {
             return;
         }
     }
     $storage = $mounts[0]->getStorage();
     $watcher = new Watcher($storage);
     $watcher->checkUpdate($internalPath);
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:25,代码来源:backgroundwatcher.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: 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

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

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

示例9: tearDown

 protected function tearDown()
 {
     if ($this->sharedCache) {
         $this->sharedCache->clear();
     }
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER);
     foreach ($shares as $share) {
         $this->shareManager->deleteShare($share);
     }
     $this->view->deleteAll('container');
     $this->ownerCache->clear();
     parent::tearDown();
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:14,代码来源:permissions.php

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

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

示例12: testUpdateLegacyAndNewId

 public function testUpdateLegacyAndNewId()
 {
     // add storage ids
     $oldCache = new \OC\Files\Cache\Cache($this->oldId);
     new \OC\Files\Cache\Cache($this->newId);
     // add file to old cache
     $fileId = $oldCache->put('/', array('size' => 0, 'mtime' => time(), 'mimetype' => 'httpd/directory'));
     try {
         $this->instance = new \OC\Files\Storage\AmazonS3($this->params);
     } catch (\Exception $e) {
         //ignore
     }
     $storages = $this->getStorages();
     $this->assertTrue(isset($storages[$this->newId]));
     $this->assertFalse(isset($storages[$this->oldId]));
     $this->assertNull(\OC\Files\Cache\Cache::getById($fileId), 'old filecache has not been cleared');
 }
开发者ID:droiter,项目名称:openwrt-on-android,代码行数:17,代码来源:amazons3migration.php

示例13: runBackgroundScanJob

 private function runBackgroundScanJob(callable $callback, $path)
 {
     try {
         $callback();
         \OC_Hook::emit('Scanner', 'correctFolderSize', array('path' => $path));
         if ($this->cacheActive && $this->cache instanceof Cache) {
             $this->cache->correctFolderSize($path);
         }
     } catch (\OCP\Files\StorageInvalidException $e) {
         // skip unavailable storages
     } catch (\OCP\Files\StorageNotAvailableException $e) {
         // skip unavailable storages
     } catch (\OCP\Files\ForbiddenException $e) {
         // skip forbidden storages
     } catch (\OCP\Lock\LockedException $e) {
         // skip unavailable storages
     }
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:18,代码来源:Scanner.php

示例14: tearDown

 protected function tearDown()
 {
     if ($this->cache) {
         $this->cache->clear();
     }
     parent::tearDown();
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:7,代码来源:cache.php

示例15: getFolderContentsById

 public function getFolderContentsById($id)
 {
     $results = parent::getFolderContentsById($id);
     foreach ($results as &$file) {
         $file['displayname_owner'] = $this->remoteUser . '@' . $this->remote;
     }
     return $results;
 }
开发者ID:evanjt,项目名称:core,代码行数:8,代码来源:cache.php


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