本文整理汇总了PHP中OC\Files\Cache\Cache类的典型用法代码示例。如果您正苦于以下问题:PHP Cache类的具体用法?PHP Cache怎么用?PHP Cache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Cache类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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
示例15: 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
示例16: 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
示例17: 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
示例18: moveFromCache
/**
* Move a file or folder in the cache
*
* @param \OC\Files\Cache\Cache $sourceCache
* @param string $sourcePath
* @param string $targetPath
* @throws \OC\DatabaseException
*/
public function moveFromCache(Cache $sourceCache, $sourcePath, $targetPath)
{
// normalize source and target
$sourcePath = $this->normalize($sourcePath);
$targetPath = $this->normalize($targetPath);
$sourceData = $sourceCache->get($sourcePath);
$sourceId = $sourceData['fileid'];
$newParentId = $this->getParentId($targetPath);
list($sourceStorageId, $sourcePath) = $sourceCache->getMoveInfo($sourcePath);
list($targetStorageId, $targetPath) = $this->getMoveInfo($targetPath);
// sql for final update
$moveSql = 'UPDATE `*PREFIX*filecache` SET `storage` = ?, `path` = ?, `path_hash` = ?, `name` = ?, `parent` =? WHERE `fileid` = ?';
if ($sourceData['mimetype'] === 'httpd/unix-directory') {
//find all child entries
$sql = 'SELECT `path`, `fileid` FROM `*PREFIX*filecache` WHERE `storage` = ? AND `path` LIKE ?';
$result = $this->connection->executeQuery($sql, [$sourceStorageId, $this->connection->escapeLikeParameter($sourcePath) . '/%']);
$childEntries = $result->fetchAll();
$sourceLength = strlen($sourcePath);
$this->connection->beginTransaction();
$query = $this->connection->prepare('UPDATE `*PREFIX*filecache` SET `storage` = ?, `path` = ?, `path_hash` = ? WHERE `fileid` = ?');
foreach ($childEntries as $child) {
$newTargetPath = $targetPath . substr($child['path'], $sourceLength);
$query->execute([$targetStorageId, $newTargetPath, md5($newTargetPath), $child['fileid']]);
}
$this->connection->executeQuery($moveSql, [$targetStorageId, $targetPath, md5($targetPath), basename($targetPath), $newParentId, $sourceId]);
$this->connection->commit();
} else {
$this->connection->executeQuery($moveSql, [$targetStorageId, $targetPath, md5($targetPath), basename($targetPath), $newParentId, $sourceId]);
}
}
开发者ID:sunblade,项目名称:core,代码行数:38,代码来源:cache.php
示例19: getLocalFileOwnerAndPath
protected function getLocalFileOwnerAndPath()
{
$fileInfo = \OC\Files\Cache\Cache::getById($this->fileId);
$owner = \OCP\User::getUser();
if (!$owner) {
throw new Exception('Guest users can\'t access local files. This one was probably unshared recently.');
}
return array($owner, @$fileInfo[1]);
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:9,代码来源:file.php
示例20: createData
/**
* Create dummy data in the filecache for the given storage numeric id
*
* @param string $storageId storage id
*/
private function createData($storageId)
{
$cache = new Cache($storageId);
$cache->put('dummyfile.txt', array('size' => 5, 'mtime' => 12, 'mimetype' => 'text/plain'));
}
开发者ID:evanjt,项目名称:core,代码行数:10,代码来源:repairlegacystorage.php
注:本文中的OC\Files\Cache\Cache类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论