ICache¶
-
interface
OCP\Files\Cache\
ICache
¶ - Metadata cache for a storageThe cache stores the metadata for all files and folders in a storage and is kept up to date trough the following mechanisms:- Scanner: scans the storage and updates the cache where needed- Watcher: checks for changes made to the filesystem outside of the ownCloud instance and rescans files and folder when a change is detected- Updater: listens to changes made to the filesystem inside of the ownCloud instance and updates the cache where needed- ChangePropagator: updates the mtime and etags of parent folders whenever a change to the cache is made to the cache by the updater
Implemented by: OC\Lockdown\Filesystem\NullCache
OC\Files\Cache\Cache
OC\Files\Cache\FailedCache
Source: lib/public/Files/Cache/ICache.php#40
Constants¶
-
NOT_FOUND = 0
Source: lib/public/Files/Cache/ICache.php#41
-
PARTIAL = 1
Source: lib/public/Files/Cache/ICache.php#42
-
SHALLOW = 2
Source: lib/public/Files/Cache/ICache.php#43
-
COMPLETE = 3
Source: lib/public/Files/Cache/ICache.php#44
Methods¶
-
public
OCP\Files\Cache\ICache::
getNumericStorageId
()¶ - Get the numeric storage id for this cache’s storage
Source: lib/public/Files/Cache/ICache.php#52 Returns: int Since: 9.0.0
-
public
OCP\Files\Cache\ICache::
get
($file)¶ - get the stored metadata of a file or folder
Source: lib/public/Files/Cache/ICache.php#61 Parameters: Returns: \OCP\Files\Cache\ICacheEntry
| bool the cache entry or false if the file is not found in the cacheSince: 9.0.0
-
public
OCP\Files\Cache\ICache::
getFolderContents
($folder)¶ - get the metadata of all files stored in $folderOnly returns files one level deep, no recursion
Source: Parameters: - $folder (string)
Returns: Since: 9.0.0
-
public
OCP\Files\Cache\ICache::
getFolderContentsById
($fileId)¶ - get the metadata of all files stored in $folderOnly returns files one level deep, no recursion
Source: Parameters: - $fileId (int) the file id of the folder
Returns: Since: 9.0.0
-
public
OCP\Files\Cache\ICache::
put
($file, $data)¶ - store meta data for a file or folderThis will automatically call either insert or update depending on if the file exists
Source: Parameters: - $file (string)
- $data (array)
Returns: int file id
Throws: \RuntimeException
Since: 9.0.0
-
public
OCP\Files\Cache\ICache::
insert
($file, $data)¶ - insert meta data for a new file or folder
Source: Parameters: - $file (string)
- $data (array)
Returns: int file id
Throws: \RuntimeException
Since: 9.0.0
-
public
OCP\Files\Cache\ICache::
update
($id, $data)¶ - update the metadata of an existing file or folder in the cache
Source: Parameters: - $id (int) the fileid of the existing file or folder
- $data (array) [$key => $value] the metadata to update, only the fields provided in the array will be updated, non-provided values will remain unchanged
Since: 9.0.0
-
public
OCP\Files\Cache\ICache::
getId
($file)¶ - get the file id for a fileA file id is a numeric id for a file or folder that’s unique within an owncloud instance which stays the same for the lifetime of a fileFile ids are easiest way for apps to store references to a file since unlike paths they are not affected by renames or sharing
Source: Parameters: - $file (string)
Returns: int
Since: 9.0.0
-
public
OCP\Files\Cache\ICache::
getParentId
($file)¶ - get the id of the parent folder of a file
Source: Parameters: - $file (string)
Returns: int
Since: 9.0.0
-
public
OCP\Files\Cache\ICache::
inCache
($file)¶ - check if a file is available in the cache
Source: Parameters: - $file (string)
Returns: bool
Since: 9.0.0
-
public
OCP\Files\Cache\ICache::
remove
($file)¶ - remove a file or folder from the cachewhen removing a folder from the cache all files and folders inside the folder will be removed as well
Source: Parameters: - $file (string)
Since: 9.0.0
-
public
OCP\Files\Cache\ICache::
move
($source, $target)¶ - Move a file or folder in the cache
Source: Parameters: - $source (string)
- $target (string)
Since: 9.0.0
-
public
OCP\Files\Cache\ICache::
moveFromCache
($sourceCache, $sourcePath, $targetPath)¶ - Move a file or folder in the cacheNote that this should make sure the entries are removed from the source cache
Source: Parameters: - $sourceCache (
OCP\Files\Cache\ICache
) - $sourcePath (string)
- $targetPath (string)
Throws: Since: 9.0.0
- $sourceCache (
-
public
OCP\Files\Cache\ICache::
copyFromCache
($sourceCache, $sourceEntry, $targetPath)¶ - Copy a file or folder in the cache
Source: Parameters: - $sourceCache (
OCP\Files\Cache\ICache
) - $sourceEntry (
OCP\Files\Cache\ICacheEntry
) - $targetPath (string)
Returns: int fileid of copied entry
Since: 22.0.0
- $sourceCache (
-
public
OCP\Files\Cache\ICache::
getStatus
($file)¶ - Get the scan status of a file- ICache::NOT_FOUND: File is not in the cache- ICache::PARTIAL: File is not stored in the cache but some incomplete data is known- ICache::SHALLOW: The folder and it’s direct children are in the cache but not all sub folders are fully scanned- ICache::COMPLETE: The file or folder, with all it’s children) are fully scanned
Source: Parameters: - $file (string)
Returns: int ICache::NOT_FOUND, ICache::PARTIAL, ICache::SHALLOW or ICache::COMPLETE
Since: 9.0.0
-
public
OCP\Files\Cache\ICache::
search
($pattern)¶ - search for files matching $pattern, files are matched if their filename matches the search pattern
Source: Parameters: - $pattern (string) the search pattern using SQL search syntax (e.g. ‘%searchstring%’)
Returns: \OCP\Files\Cache\ICacheEntry[]
an array of cache entries where the name matches the search patternSince: 9.0.0
Deprecated: 9.0.0 due to lack of pagination, not all backends might implement this
-
public
OCP\Files\Cache\ICache::
searchByMime
($mimetype)¶ - search for files by mimetype
Source: Parameters: - $mimetype (string) either a full mimetype to search (‘text/plain’) or only the first part of a mimetype (‘image’)
where it will search for all mimetypes in the group (‘image/*‘)
Returns: \OCP\Files\Cache\ICacheEntry[]
an array of cache entries where the mimetype matches the searchSince: 9.0.0
Deprecated: 9.0.0 due to lack of pagination, not all backends might implement this
-
public
OCP\Files\Cache\ICache::
searchQuery
($query)¶ - Search for files with a flexible query
Source: Parameters: - $query (
OCP\Files\Search\ISearchQuery
)
Returns: Throws: \InvalidArgumentException
if the cache is unable to perform the querySince: 12.0.0
- $query (
-
public
OCP\Files\Cache\ICache::
getIncomplete
()¶ - find a folder in the cache which has not been fully scannedIf multiple incomplete folders are in the cache, the one with the highest id will be returned,use the one with the highest id gives the best result with the background scanner, since that is mostlikely the folder where we stopped scanning previously
Source: lib/public/Files/Cache/ICache.php#249 Returns: string | bool the path of the folder or false when no folder matched Since: 9.0.0
-
public
OCP\Files\Cache\ICache::
getPathById
($id)¶ - get the path of a file on this storage by it’s file id
Source: Parameters: - $id (int) the file id of the file or folder to search
Returns: string | null the path of the file (relative to the storage) or null if a file with the given id does not exists within this cache
Since: 9.0.0
-
public
OCP\Files\Cache\ICache::
normalize
($path)¶ - normalize the given path for usage in the cache
Source: Parameters: - $path (string)
Returns: string
Since: 9.0.0