本文整理汇总了PHP中OC\Files\Storage\Storage::getCache方法的典型用法代码示例。如果您正苦于以下问题:PHP Storage::getCache方法的具体用法?PHP Storage::getCache怎么用?PHP Storage::getCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\Files\Storage\Storage
的用法示例。
在下文中一共展示了Storage::getCache方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
// remember files_encryption state
$this->stateFilesEncryption = \OC_App::isEnabled('files_encryption');
// we want to tests with the encryption app disabled
\OC_App::disable('files_encryption');
$this->storage = new \OC\Files\Storage\Temporary(array());
$textData = "dummy file data\n";
$imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png');
$this->storage->mkdir('folder');
$this->storage->file_put_contents('foo.txt', $textData);
$this->storage->file_put_contents('foo.png', $imgData);
$this->storage->file_put_contents('folder/bar.txt', $textData);
$this->storage->file_put_contents('folder/bar2.txt', $textData);
$this->scanner = $this->storage->getScanner();
$this->scanner->scan('');
$this->cache = $this->storage->getCache();
\OC\Files\Filesystem::tearDown();
if (!self::$user) {
self::$user = uniqid();
}
\OC_User::createUser(self::$user, 'password');
\OC_User::setUserId(self::$user);
\OC\Files\Filesystem::init(self::$user, '/' . self::$user . '/files');
Filesystem::clearMounts();
Filesystem::mount($this->storage, array(), '/' . self::$user . '/files');
\OC_Hook::clear('OC_Filesystem');
}
示例2: setUp
protected function setUp()
{
parent::setUp();
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
// prepare user1's dir structure
$textData = "dummy file data\n";
$this->view->mkdir('container');
$this->view->mkdir('container/shareddir');
$this->view->mkdir('container/shareddir/subdir');
$this->view->mkdir('container/shareddirrestricted');
$this->view->mkdir('container/shareddirrestricted/subdir');
$this->view->file_put_contents('container/shareddir/textfile.txt', $textData);
$this->view->file_put_contents('container/shareddirrestricted/textfile1.txt', $textData);
list($this->ownerStorage, $internalPath) = $this->view->resolvePath('');
$this->ownerCache = $this->ownerStorage->getCache();
$this->ownerStorage->getScanner()->scan('');
// share "shareddir" with user2
$fileinfo = $this->view->getFileInfo('container/shareddir');
\OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
$fileinfo2 = $this->view->getFileInfo('container/shareddirrestricted');
\OCP\Share::shareItem('folder', $fileinfo2['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 7);
// login as user2
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
// retrieve the shared storage
$this->secondView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2);
list($this->sharedStorage, $internalPath) = $this->secondView->resolvePath('files/shareddir');
list($this->sharedStorageRestrictedShare, $internalPath) = $this->secondView->resolvePath('files/shareddirrestricted');
$this->sharedCache = $this->sharedStorage->getCache();
$this->sharedCacheRestrictedShare = $this->sharedStorageRestrictedShare->getCache();
}
示例3: setUp
protected function setUp()
{
parent::setUp();
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
// prepare user1's dir structure
$textData = "dummy file data\n";
$this->view->mkdir('container');
$this->view->mkdir('container/shareddir');
$this->view->mkdir('container/shareddir/subdir');
$this->view->mkdir('container/shareddirrestricted');
$this->view->mkdir('container/shareddirrestricted/subdir');
$this->view->file_put_contents('container/shareddir/textfile.txt', $textData);
$this->view->file_put_contents('container/shareddirrestricted/textfile1.txt', $textData);
list($this->ownerStorage, $internalPath) = $this->view->resolvePath('');
$this->ownerCache = $this->ownerStorage->getCache();
$this->ownerStorage->getScanner()->scan('');
// share "shareddir" with user2
$rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1);
$node = $rootFolder->get('container/shareddir');
$share = $this->shareManager->newShare();
$share->setNode($node)->setShareType(\OCP\Share::SHARE_TYPE_USER)->setSharedWith(self::TEST_FILES_SHARING_API_USER2)->setSharedBy(self::TEST_FILES_SHARING_API_USER1)->setPermissions(\OCP\Constants::PERMISSION_ALL);
$this->shareManager->createShare($share);
$node = $rootFolder->get('container/shareddirrestricted');
$share = $this->shareManager->newShare();
$share->setNode($node)->setShareType(\OCP\Share::SHARE_TYPE_USER)->setSharedWith(self::TEST_FILES_SHARING_API_USER2)->setSharedBy(self::TEST_FILES_SHARING_API_USER1)->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE);
$this->shareManager->createShare($share);
// login as user2
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
// retrieve the shared storage
$this->secondView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2);
list($this->sharedStorage, $internalPath) = $this->secondView->resolvePath('files/shareddir');
list($this->sharedStorageRestrictedShare, $internalPath) = $this->secondView->resolvePath('files/shareddirrestricted');
$this->sharedCache = $this->sharedStorage->getCache();
$this->sharedCacheRestrictedShare = $this->sharedStorageRestrictedShare->getCache();
}
示例4: setUp
protected function setUp() {
parent::setUp();
$this->storage = new \OC\Files\Storage\Temporary(array());
$textData = "dummy file data\n";
$imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png');
$this->storage->mkdir('folder');
$this->storage->file_put_contents('foo.txt', $textData);
$this->storage->file_put_contents('foo.png', $imgData);
$this->storage->file_put_contents('folder/bar.txt', $textData);
$this->storage->file_put_contents('folder/bar2.txt', $textData);
$this->scanner = $this->storage->getScanner();
$this->scanner->scan('');
$this->cache = $this->storage->getCache();
if (!self::$user) {
self::$user = $this->getUniqueID();
}
\OC_User::createUser(self::$user, 'password');
$this->loginAsUser(self::$user);
Filesystem::init(self::$user, '/' . self::$user . '/files');
Filesystem::clearMounts();
Filesystem::mount($this->storage, array(), '/' . self::$user . '/files');
\OC_Hook::clear('OC_Filesystem');
}
示例5: setUp
protected function setUp()
{
parent::setUp();
$this->loginAsUser();
$this->storage = new Temporary(array());
$this->updater = $this->storage->getUpdater();
$this->cache = $this->storage->getCache();
}
示例6: setUp
public function setUp()
{
$this->storage = new Temporary(array());
Filesystem::clearMounts();
Filesystem::mount($this->storage, array(), '/');
$this->view = new View('');
$this->updater = new \OC\Files\Cache\Updater($this->view);
$this->cache = $this->storage->getCache();
}
示例7: setUp
protected function setUp()
{
parent::setUp();
$this->loginAsUser();
$this->storage = new Temporary(array());
Filesystem::mount($this->storage, array(), '/');
$this->view = new View('');
$this->updater = new \OC\Files\Cache\Updater($this->view);
$this->cache = $this->storage->getCache();
}
示例8: setUp
protected function setUp()
{
parent::setUp();
$this->originalStorage = Filesystem::getStorage('/');
$this->storage = new Temporary(array());
Filesystem::clearMounts();
Filesystem::mount($this->storage, array(), '/');
$this->view = new View('');
$this->updater = new \OC\Files\Cache\Updater($this->view);
$this->cache = $this->storage->getCache();
}
示例9: tearDown
protected function tearDown()
{
$this->user = null;
if ($this->storageMock) {
$this->storageMock->getCache()->clear();
$this->storageMock = null;
}
\OC\Files\Filesystem::tearDown();
\OC\Files\Filesystem::mount($this->storage, array(), '/');
\OC_User::setUserId('');
\OC_User::deleteUser($this->user);
\OC::$server->getConfig()->deleteAllUserValues($this->user);
parent::tearDown();
}
示例10: testDontLowerMtime
public function testDontLowerMtime()
{
$time = time();
$this->view->mkdir('/foo');
$this->view->mkdir('/foo/bar');
$cache = $this->storage->getCache();
$cache->put('', ['mtime' => $time - 50]);
$cache->put('foo', ['mtime' => $time - 150]);
$cache->put('foo/bar', ['mtime' => $time - 250]);
$this->propagator->addChange('/foo/bar/foo');
$this->propagator->propagateChanges($time - 100);
$this->assertEquals(50, $time - $cache->get('')['mtime']);
$this->assertEquals(100, $time - $cache->get('foo')['mtime']);
$this->assertEquals(100, $time - $cache->get('foo/bar')['mtime']);
}
示例11: __construct
public function __construct(\OC\Files\Storage\Storage $storage)
{
$this->storage = $storage;
$this->storageId = $this->storage->getId();
$this->cache = $storage->getCache();
$this->cacheActive = !Config::getSystemValue('filesystem_cache_readonly', false);
}
示例12: __construct
/**
* @param \OC\Files\Storage\Storage $storage
*/
public function __construct(\OC\Files\Storage\Storage $storage)
{
$this->storage = $storage;
$this->propagator = $storage->getPropagator();
$this->scanner = $storage->getScanner();
$this->cache = $storage->getCache();
}
示例13: getCache
/**
* get a cache instance for the storage
*
* @param string $path
* @param \OC\Files\Storage\Storage (optional) the storage to pass to the cache
* @return \OC\Files\Cache\Cache
*/
public function getCache($path = '', $storage = null)
{
if (!$storage) {
$storage = $this;
}
return $this->storage->getCache($path, $storage);
}
示例14: __construct
public function __construct(\OC\Files\Storage\Storage $storage)
{
$this->storage = $storage;
$this->storageId = $this->storage->getId();
$this->cache = $storage->getCache();
$this->permissionsCache = $storage->getPermissionsCache();
}
示例15: propagateChange
/**
* @param string $internalPath
* @param int $time
* @return array[] all propagated entries
*/
public function propagateChange($internalPath, $time)
{
$cache = $this->storage->getCache($internalPath);
$parentId = $cache->getParentId($internalPath);
$propagatedEntries = [];
while ($parentId !== -1) {
$entry = $cache->get($parentId);
$propagatedEntries[] = $entry;
if (!$entry) {
return $propagatedEntries;
}
$mtime = max($time, $entry['mtime']);
$cache->update($parentId, ['mtime' => $mtime, 'etag' => $this->storage->getETag($entry['path'])]);
$parentId = $entry['parent'];
}
return $propagatedEntries;
}