本文整理汇总了PHP中OC\Files\Cache\Cache::getById方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::getById方法的具体用法?PHP Cache::getById怎么用?PHP Cache::getById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\Files\Cache\Cache
的用法示例。
在下文中一共展示了Cache::getById方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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');
}
示例3: testLongId
function testLongId()
{
$storage = new LongId(array());
$cache = $storage->getCache();
$storageId = $storage->getId();
$data = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file');
$id = $cache->put('foo', $data);
$this->assertEquals(array(md5($storageId), 'foo'), \OC\Files\Cache\Cache::getById($id));
}
示例4: getById
/**
* get the storage id of the storage for a file and the internal path of the file
* unlike getPathById this does not limit the search to files on this storage and
* instead does a global search in the cache table
*
* @param int $id
* @return array, first element holding the storage id, second the path
*/
public static function getById($id)
{
return parent::getById($id);
}
示例5: 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]);
}
示例6: getPathWithMountPoint
/**
* Get the path including the storage mount point
* @param int $id
* @return string the path including the mount point like AmazonS3/folder/file.txt
*/
public function getPathWithMountPoint($id)
{
list($storage, $internalPath) = \OC\Files\Cache\Cache::getById($id);
$mount = \OC\Files\Filesystem::getMountByStorageId($storage);
$mountPoint = $mount[0]->getMountPoint();
$path = \OC\Files\Filesystem::normalizePath($mountPoint . '/' . $internalPath);
// reformat the path to be relative e.g. /user/files/folder becomes /folder/
$relativePath = \OCA\Encryption\Helper::stripUserFilesPath($path);
return $relativePath;
}
示例7: getById
/**
* search file by id
*
* An array is returned because in the case where a single storage is mounted in different places the same file
* can exist in different places
*
* @param int $id
* @throws \OCP\Files\NotFoundException
* @return Node[]
*/
public function getById($id)
{
$result = Cache::getById($id);
if (is_null($result)) {
throw new NotFoundException();
} else {
list($storageId, $internalPath) = $result;
$nodes = array();
$mounts = $this->mountManager->findByStorageId($storageId);
foreach ($mounts as $mount) {
$nodes[] = $this->get($mount->getMountPoint() . $internalPath);
}
return $nodes;
}
}
示例8: isValidSource
public function isValidSource($itemSource, $uidOwner)
{
return is_array(\OC\Files\Cache\Cache::getById($itemSource));
}