Cache¶
-
class
OC\Files\Cache\
Cache
¶ - 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
Source: lib/private/Files/Cache/Cache.php#69 Implements: OCP\Files\Cache\ICache
Used traits: OC\Files\Cache\MoveFromCacheTrait
Properties¶
-
protected static property
OC\Files\Cache\Cache::$
partial
¶ Source: lib/private/Files/Cache/Cache.php#77 Type: array partial data for the cache
-
protected static property
OC\Files\Cache\Cache::$
storageId
¶ Source: lib/private/Files/Cache/Cache.php#82 Type: string
-
protected static property
OC\Files\Cache\Cache::$
storageCache
¶ Source: lib/private/Files/Cache/Cache.php#89 Type: \OC\Files\Cache\Storage
-
protected static property
OC\Files\Cache\Cache::$
mimetypeLoader
¶ Source: lib/private/Files/Cache/Cache.php#92 Type: \OCP\Files\IMimeTypeLoader
-
protected static property
OC\Files\Cache\Cache::$
connection
¶ Source: lib/private/Files/Cache/Cache.php#97 Type: \OCP\IDBConnection
-
protected static property
OC\Files\Cache\Cache::$
eventDispatcher
¶ Source: lib/private/Files/Cache/Cache.php#102 Type: \OCP\EventDispatcher\IEventDispatcher
-
protected static property
OC\Files\Cache\Cache::$
querySearchHelper
¶ Source: lib/private/Files/Cache/Cache.php#105 Type: \OC\Files\Cache\QuerySearchHelper
Methods¶
-
public
OC\Files\Cache\Cache::
__construct
($storage)¶ Source: Parameters: - $storage (
OCP\Files\Storage\IStorage
)
- $storage (
-
protected
OC\Files\Cache\Cache::
getQueryBuilder
()¶ Source: lib/private/Files/Cache/Cache.php#124
-
public
OC\Files\Cache\Cache::
getNumericStorageId
()¶ - Get the numeric storage id for this cache’s storage
Source: lib/private/Files/Cache/Cache.php#138 Returns: int
-
public
OC\Files\Cache\Cache::
get
($file)¶ - get the stored metadata of a file or folder
Source: lib/private/Files/Cache/Cache.php#148 Parameters: Returns: \OCP\Files\Cache\ICacheEntry
| bool the cache entry as array of false if the file is not found in the cache
-
public static
OC\Files\Cache\Cache::
cacheEntryFromData
($data, $mimetypeLoader)¶ - Create a CacheEntry from database row
Source: Parameters: - $data (array)
- $mimetypeLoader (
OCP\Files\IMimeTypeLoader
)
Returns:
-
public
OC\Files\Cache\Cache::
getFolderContents
($folder)¶ - get the metadata of all files stored in $folder
Source: Parameters: - $folder (string)
Returns:
-
public
OC\Files\Cache\Cache::
getFolderContentsById
($fileId)¶ - get the metadata of all files stored in $folder
Source: Parameters: - $fileId (int) the file id of the folder
Returns:
-
public
OC\Files\Cache\Cache::
put
($file, $data)¶ - insert or update meta data for a file or folder
Source: Parameters: - $file (string)
- $data (array)
Returns: int file id
Throws: \RuntimeException
-
public
OC\Files\Cache\Cache::
insert
($file, $data)¶ - insert meta data for a new file or folder
Source: Parameters: - $file (string)
- $data (array)
Returns: int file id
Throws: \RuntimeException
-
public
OC\Files\Cache\Cache::
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
-
protected
OC\Files\Cache\Cache::
normalizeData
($data)¶ - extract query parts and params array from data array
Source: Parameters: - $data (array)
Returns: array
-
public
OC\Files\Cache\Cache::
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
-
public
OC\Files\Cache\Cache::
getParentId
($file)¶ - get the id of the parent folder of a file
Source: Parameters: - $file (string)
Returns: int
-
public
OC\Files\Cache\Cache::
inCache
($file)¶ - check if a file is available in the cache
Source: Parameters: - $file (string)
Returns: bool
-
public
OC\Files\Cache\Cache::
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)
-
public
OC\Files\Cache\Cache::
move
($source, $target)¶ - Move a file or folder in the cache
Source: Parameters: - $source (string)
- $target (string)
-
protected
OC\Files\Cache\Cache::
getMoveInfo
($path)¶ - Get the storage id and path needed for a move
Source: Parameters: - $path (string)
Returns: array [$storageId, $internalPath]
-
public
OC\Files\Cache\Cache::
moveFromCache
($sourceCache, $sourcePath, $targetPath)¶ - Move a file or folder in the cache
Source: Parameters: - $sourceCache (
OCP\Files\Cache\ICache
) - $sourcePath (string)
- $targetPath (string)
Throws: Throws: \Exception
if the given storages have an invalid idThrows: Throws: \Exception
if the given storages have an invalid id - $sourceCache (
-
public
OC\Files\Cache\Cache::
clear
()¶ - remove all entries for files that are stored on the storage from the cache
Source: lib/private/Files/Cache/Cache.php#718
-
public
OC\Files\Cache\Cache::
getStatus
($file)¶ - Get the scan status of a file- Cache::NOT_FOUND: File is not in the cache- Cache::PARTIAL: File is not stored in the cache but some incomplete data is known- Cache::SHALLOW: The folder and it’s direct children are in the cache but not all sub folders are fully scanned- Cache::COMPLETE: The file or folder, with all it’s children) are fully scanned
Source: Parameters: - $file (string)
Returns: int Cache::NOT_FOUND, Cache::PARTIAL, Cache::SHALLOW or Cache::COMPLETE
-
public
OC\Files\Cache\Cache::
search
($pattern)¶ - search for files matching $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 pattern
-
public
OC\Files\Cache\Cache::
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 search
-
public
OC\Files\Cache\Cache::
searchQuery
($searchQuery)¶ Source: lib/private/Files/Cache/Cache.php#840
-
public
OC\Files\Cache\Cache::
correctFolderSize
($path, $data=null, $isBackgroundScan=false)¶ - Re-calculate the folder size and the size of all parent folders
Source: Parameters: - $path (string | bool)
- $data (array) (optional) meta data of the folder
-
public
OC\Files\Cache\Cache::
getIncompleteChildrenCount
($fileId)¶ - get the incomplete count that shares parent $folder
Source: Parameters: - $fileId (int) the file id of the folder
Returns: int
-
public
OC\Files\Cache\Cache::
calculateFolderSize
($path, $entry=null)¶ - calculate the size of a folder and set it in the cache
Source: Parameters: - $path (string)
- $entry (array) (optional) meta data of the folder
Returns: int
-
public
OC\Files\Cache\Cache::
getAll
()¶ - get all file ids on the files on the storage
Source: lib/private/Files/Cache/Cache.php#981 Returns: int[]
-
public
OC\Files\Cache\Cache::
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/private/Files/Cache/Cache.php#1005 Returns: string | bool the path of the folder or false when no folder matched
-
public
OC\Files\Cache\Cache::
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
-
public static
OC\Files\Cache\Cache::
getById
($id)¶ - get the storage id of the storage for a file and the internal path of the fileunlike getPathById this does not limit the search to files on this storage andinstead does a global search in the cache table
Source: Parameters: - $id (int)
Returns: array first element holding the storage id, second the path
Deprecated: use getPathById() instead
-
public
OC\Files\Cache\Cache::
normalize
($path)¶ - normalize the given path
Source: Parameters: - $path (string)
Returns: string
-
public
OC\Files\Cache\Cache::
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
- $sourceCache (