|
eZ Publish
[4.2]
|
Public Member Functions | |
| __get ($propertyName) | |
| Magic getter. | |
| abortCacheGeneration () | |
| Aborts the current cache generation process. | |
| checkCacheGenerationTimeout () | |
| Checks if the .generating file was changed, which would mean that generation timed out. | |
| deleteLocal () | |
| Deletes a file that has been fetched before. | |
| endCacheGeneration ($rename=true) | |
| Ends the cache generation started by startCacheGeneration(). | |
| exists () | |
| Check if given file/dir exists. | |
| eZDBFileHandler ($filePath=false) | |
| Constructor. | |
| fetch ($noLocalCache=false) | |
| Fetches file from db and saves it in FS under the same name. | |
| fetchContents () | |
| Returns file contents. | |
| fetchExpiredBinaryItems ($limit=array(0, 100)) | |
| Fetches the first $limit expired binary items from the DB. | |
| fetchExpiredItems ($scopes, $limit=array(0, 100), $expiry=false) | |
| Fetches the first $limit expired files from the DB. | |
| fileStoreContents ($filePath, $contents, $scope=false, $datatype=false) | |
| Store file contents. | |
| getFileList ($scopes=false, $excludeScopes=false) | |
| Get list of files stored in database. | |
| isDBFileExpired ($expiry, $curtime, $ttl) | |
| Calculates if the DB file is expired or not. | |
| isExpired ($expiry, $curtime, $ttl) | |
| Calculates if the current file data is expired or not. | |
| isLocalFileExpired ($expiry, $curtime, $ttl) | |
| Calculates if the local file is expired or not. | |
| loadMetaData ($force=false) | |
| move ($dstPath) | |
| Move file. | |
| mtime () | |
| Returns file modification time. | |
| name () | |
| Returns file name. | |
| passthrough () | |
| Outputs file contents prepending them with appropriate HTTP headers. | |
| processCache ($retrieveCallback, $generateCallback=null, $ttl=null, $expiry=null, $extraData=null) | |
| processFile ($callback, $expiry=false, $extraData=null) | |
| purge ($printCallback=false, $microsleep=false, $max=false, $expiry=false) | |
| requiresBinaryPurge () | |
| eZDB does require binary purge. | |
| requiresClusterizing () | |
| Since eZDB uses the database, running clusterize.php is required. | |
| requiresPurge () | |
| eZDB does require binary purge. | |
| size () | |
| Returns file size. | |
| startCacheGeneration () | |
| Starts cache generation for the current file. | |
| stat () | |
| Returns file metadata. | |
| storeContents ($contents, $scope=false, $datatype=false, $storeLocally=false) | |
| Store file contents. | |
Static Public Member Functions | |
| static | cleanPath ($path) |
| Returns a clean version of input $path. | |
| delete () | |
| Deletes specified file/directory. | |
| fetchUnique () | |
| Fetches file from db and saves it in FS under unique name. | |
| fileCopy ($srcPath, $dstPath) | |
| Copy file. | |
| fileDelete ($path, $fnamePart=false) | |
| Deletes specified file/directory. | |
| fileDeleteByDirList ($dirList, $commonPath, $commonSuffix) | |
| fileDeleteByRegex ($dir, $fileRegex) | |
| fileDeleteByWildcard ($wildcard) | |
| fileDeleteLocal ($path) | |
| Deletes a file that has been fetched before. | |
| fileExists ($path) | |
| Check if given file/dir exists. | |
| fileFetch ($filePath) | |
| Fetches file from db and saves it in FS under the same name. | |
| fileFetchContents ($filePath) | |
| Returns file contents. | |
| fileLinkCopy ($srcPath, $dstPath, $symLink) | |
| Create symbolic or hard link to file. | |
| fileMove ($srcPath, $dstPath) | |
| Move file. | |
| fileStore ($filePath, $scope=false, $delete=false, $datatype=false) | |
| static | isFileExpired ($fname, $mtime, $expiry, $curtime, $ttl) |
| Calculates if the file data is expired or not. | |
Public Attributes | |
| $backend | |
| $backendVerify | |
| $filePath | |
| $metaData = null | |
| holds the file's metaData loaded from database The variable's type indicates the exact status: | |
| $realFilePath = null | |
| holds the real file path. | |
| const | INFOCACHE_MAX = 200 |
| const | LOCAL_CACHE = 1 |
Private Member Functions | |
| _cacheType () | |
| Determines the cache type based on the path. | |
| storeCache ($fileData) | |
Private Attributes | |
| $generationStartTimestamp = false | |
| $nonExistantStaleCacheHandling | |
| Holds the preferences used when stale cache is activated and no expired file is available. | |
| $remainingCacheGenerationTime = false | |
| $useStaleCache = false | |
Definition at line 36 of file ezdbfilehandler.php.
| eZDBFileHandler::__get | ( | $ | propertyName | ) |
Magic getter.
Definition at line 1298 of file ezdbfilehandler.php.
| eZDBFileHandler::_cacheType | ( | ) | [private] |
Determines the cache type based on the path.
Definition at line 1285 of file ezdbfilehandler.php.
Referenced by __get().
| eZDBFileHandler::abortCacheGeneration | ( | ) |
Aborts the current cache generation process.
Does so by rolling back the current transaction, which should be the .generating file lock
Definition at line 1263 of file ezdbfilehandler.php.
Referenced by storeCache().
| eZDBFileHandler::checkCacheGenerationTimeout | ( | ) |
Checks if the .generating file was changed, which would mean that generation timed out.
If not timed out, refreshes the timestamp so that storage won't be stolen
Definition at line 1276 of file ezdbfilehandler.php.
Referenced by storeCache().
| static eZDBFileHandler::cleanPath | ( | $ | path | ) | [static] |
Returns a clean version of input $path.
Examples:
Definition at line 1195 of file ezdbfilehandler.php.
Referenced by eZDBFileHandler(), fileCopy(), fileDelete(), fileDeleteByDirList(), fileDeleteByRegex(), fileDeleteByWildcard(), fileDeleteLocal(), eZDFSFileHandler\fileDeleteLocal(), fileExists(), fileFetch(), fileFetchContents(), fileLinkCopy(), fileMove(), fileStore(), fileStoreContents(), and move().
| eZDBFileHandler::delete | ( | ) | [static] |
Deletes specified file/directory.
If a directory specified it is deleted recursively.
Definition at line 970 of file ezdbfilehandler.php.
| eZDBFileHandler::deleteLocal | ( | ) |
Deletes a file that has been fetched before.
Definition at line 1002 of file ezdbfilehandler.php.
| eZDBFileHandler::endCacheGeneration | ( | $ | rename = true | ) |
Ends the cache generation started by startCacheGeneration().
Definition at line 1242 of file ezdbfilehandler.php.
Referenced by storeCache().
| eZDBFileHandler::exists | ( | ) |
Check if given file/dir exists.
NOTE: this function does not interact with database. Instead, it just returns existance status determined in the constructor.
Definition at line 1066 of file ezdbfilehandler.php.
| eZDBFileHandler::eZDBFileHandler | ( | $ | filePath = false | ) |
Constructor.
$filePath File path. If specified, file metadata is fetched in the constructor.
Definition at line 55 of file ezdbfilehandler.php.
| eZDBFileHandler::fetch | ( | $ | noLocalCache = false | ) |
Fetches file from db and saves it in FS under the same name.
Definition at line 791 of file ezdbfilehandler.php.
Referenced by processCache().
| eZDBFileHandler::fetchContents | ( | ) |
Returns file contents.
Definition at line 830 of file ezdbfilehandler.php.
| eZDBFileHandler::fetchExpiredBinaryItems | ( | $ | limit = array( 0, 100 ) | ) |
Fetches the first $limit expired binary items from the DB.
| array | $limit | A 2 items array( offset, limit ) |
Definition at line 1357 of file ezdbfilehandler.php.
| eZDBFileHandler::fetchExpiredItems | ( | $ | scopes, |
| $ | limit = array( 0 , 100 ), |
||
| $ | expiry = false |
||
| ) |
Fetches the first $limit expired files from the DB.
| array | $scopes | Array of scopes to fetch from |
| array | $limit | A 2 items array( offset, limit ) |
| int | $expiry | Number of seconds, only items older than this will be returned |
Definition at line 1372 of file ezdbfilehandler.php.
| eZDBFileHandler::fetchUnique | ( | ) | [static] |
Fetches file from db and saves it in FS under unique name.
Definition at line 776 of file ezdbfilehandler.php.
Referenced by processCache().
| eZDBFileHandler::fileCopy | ( | $ | srcPath, |
| $ | dstPath | ||
| ) | [static] |
Copy file.
Definition at line 1108 of file ezdbfilehandler.php.
| eZDBFileHandler::fileDelete | ( | $ | path, |
| $ | fnamePart = false |
||
| ) | [static] |
Deletes specified file/directory.
If a directory specified it is deleted recursively.
Definition at line 947 of file ezdbfilehandler.php.
| eZDBFileHandler::fileDeleteByDirList | ( | $ | dirList, |
| $ | commonPath, | ||
| $ | commonSuffix | ||
| ) | [static] |
Definition at line 925 of file ezdbfilehandler.php.
| eZDBFileHandler::fileDeleteByRegex | ( | $ | dir, |
| $ | fileRegex | ||
| ) | [static] |
Definition at line 896 of file ezdbfilehandler.php.
| eZDBFileHandler::fileDeleteByWildcard | ( | $ | wildcard | ) | [static] |
Definition at line 912 of file ezdbfilehandler.php.
| eZDBFileHandler::fileDeleteLocal | ( | $ | path | ) | [static] |
Deletes a file that has been fetched before.
Definition at line 987 of file ezdbfilehandler.php.
Referenced by processCache().
| eZDBFileHandler::fileExists | ( | $ | path | ) | [static] |
Check if given file/dir exists.
Definition at line 1049 of file ezdbfilehandler.php.
| eZDBFileHandler::fileFetch | ( | $ | filePath | ) | [static] |
Fetches file from db and saves it in FS under the same name.
Definition at line 212 of file ezdbfilehandler.php.
| eZDBFileHandler::fileFetchContents | ( | $ | filePath | ) | [static] |
Returns file contents.
Definition at line 815 of file ezdbfilehandler.php.
| eZDBFileHandler::fileLinkCopy | ( | $ | srcPath, |
| $ | dstPath, | ||
| $ | symLink | ||
| ) | [static] |
Create symbolic or hard link to file.
Definition at line 1123 of file ezdbfilehandler.php.
| eZDBFileHandler::fileMove | ( | $ | srcPath, |
| $ | dstPath | ||
| ) | [static] |
Move file.
Definition at line 1138 of file ezdbfilehandler.php.
| eZDBFileHandler::fileStore | ( | $ | filePath, |
| $ | scope = false, |
||
| $ | delete = false, |
||
| $ | datatype = false |
||
| ) | [static] |
| $filePath | Path to the file being stored. |
| $scope | Means something like "file category". May be used to clean caches of a certain type. |
| $delete | true if the file should be deleted after storing. |
Definition at line 141 of file ezdbfilehandler.php.
| eZDBFileHandler::fileStoreContents | ( | $ | filePath, |
| $ | contents, | ||
| $ | scope = false, |
||
| $ | datatype = false |
||
| ) |
Store file contents.
| string | $filePath | |
| mixed | $contents | |
| string | $scope | |
| string | $datatype |
Definition at line 168 of file ezdbfilehandler.php.
| eZDBFileHandler::getFileList | ( | $ | scopes = false, |
| $ | excludeScopes = false |
||
| ) |
Get list of files stored in database.
Used in bin/php/clusterize.php.
| array | $scopes | return only files that belong to any of these scopes |
| boolean | $excludeScopes | if true, then reverse the meaning of $scopes, which is return only files that do not belong to any of the scopes listed in $scopes |
Definition at line 1175 of file ezdbfilehandler.php.
| eZDBFileHandler::isDBFileExpired | ( | $ | expiry, |
| $ | curtime, | ||
| $ | ttl | ||
| ) |
Calculates if the DB file is expired or not.
| int | $expiry | Time when file is to be expired, a value of -1 will disable this check. |
| int | $curtime | The current time to check against. |
| int | $ttl | Number of seconds the data can live, set to null to disable TTL. |
Definition at line 636 of file ezdbfilehandler.php.
Referenced by processCache().
| eZDBFileHandler::isExpired | ( | $ | expiry, |
| $ | curtime, | ||
| $ | ttl | ||
| ) |
Calculates if the current file data is expired or not.
| int | $expiry | Time when file is to be expired, a value of -1 will disable this check. |
| int | $curtime | The current time to check against. |
| int | $ttl | Number of seconds the data can live, set to null to disable TTL. |
Definition at line 609 of file ezdbfilehandler.php.
| static eZDBFileHandler::isFileExpired | ( | $ | fname, |
| $ | mtime, | ||
| $ | expiry, | ||
| $ | curtime, | ||
| $ | ttl | ||
| ) | [static] |
Calculates if the file data is expired or not.
| string | $fname | Name of file, available for easy debugging. |
| int | $mtime | Modification time of file, can be set to false if file does not exist. |
| int | $expiry | Time when file is to be expired, a value of -1 will disable this check. |
| int | $curtime | The current time to check against. |
| int | $ttl | Number of seconds the data can live, set to null to disable TTL. |
Definition at line 583 of file ezdbfilehandler.php.
Referenced by eZDBFileHandlerMysqlBackend\_verifyExclusiveLock(), isDBFileExpired(), isExpired(), and isLocalFileExpired().
| eZDBFileHandler::isLocalFileExpired | ( | $ | expiry, |
| $ | curtime, | ||
| $ | ttl | ||
| ) |
Calculates if the local file is expired or not.
| int | $expiry | Time when file is to be expired, a value of -1 will disable this check. |
| int | $curtime | The current time to check against. |
| int | $ttl | Number of seconds the data can live, set to null to disable TTL. |
Definition at line 624 of file ezdbfilehandler.php.
Referenced by processCache().
| eZDBFileHandler::loadMetaData | ( | $ | force = false | ) |
Load file meta information.
| $force | File stats will be refreshed if true |
Definition at line 91 of file ezdbfilehandler.php.
Referenced by isExpired(), mtime(), passthrough(), processCache(), size(), and stat().
| eZDBFileHandler::move | ( | $ | dstPath | ) |
Move file.
Definition at line 1154 of file ezdbfilehandler.php.
| eZDBFileHandler::mtime | ( | ) |
Returns file modification time.
Definition at line 870 of file ezdbfilehandler.php.
| eZDBFileHandler::name | ( | ) |
Returns file name.
Definition at line 884 of file ezdbfilehandler.php.
| eZDBFileHandler::passthrough | ( | ) |
Outputs file contents prepending them with appropriate HTTP headers.
Definition at line 1080 of file ezdbfilehandler.php.
| eZDBFileHandler::processCache | ( | $ | retrieveCallback, |
| $ | generateCallback = null, |
||
| $ | ttl = null, |
||
| $ | expiry = null, |
||
| $ | extraData = null |
||
| ) |
Creates a single transaction out of the typical file operations for accessing caches. Caches are normally ready from the database or local file, if the entry does not exist or is expired then it generates the new cache data and stores it. This method takes care of these operations and handles the custom code by performing callbacks when needed.
The $retrieveCallback is used when the file contents can be used (ie. not re-generation) and is called when the file is ready locally. The function will be called with the file path as the first parameter, the mtime as the second and optionally $extraData as the third. The function must return the file contents or an instance of eZClusterFileFailure which can be used to tell the system that the retrieve data cannot be used after all. $retrieveCallback can be set to null which makes the system go directly to the generation.
The $generateCallback is used when the file content is expired or does not exist, in this case the content must be re-generated and stored. The function will be called with the file path as the first parameter and optionally $extraData as the second. The function must return an array with information on the contents, the array consists of:
Either *content* or *binarydata* must be supplied, if not an error is issued and it returns null. If *content* is set it will be used as the return value of this function, if not it will return the binary data. If *binarydata* is set it will be used as the binary data for the file, if not it will perform a var_export on *content* and use that as the binary data.
For convenience the $generateCallback function can return a string which will be considered as the binary data for the file and returned as the content.
For controlling how long a cache entry can be used the parameters $expiry and $ttl is used. $expiry can be set to a timestamp which controls the absolute max time for the cache, after this time/date the cache will never be used. If the value is set to a negative value or null there the expiration check is disabled.
$ttl (time to live) tells how many seconds the cache can live from the time it was stored. If the value is set to negative or null there is no limit for the lifetime of the cache. A value of 0 means that the cache will always expire and practically disables caching. For the cache to be used both the $expiry and $ttl check must hold.
Definition at line 265 of file ezdbfilehandler.php.
Referenced by processFile().
| eZDBFileHandler::processFile | ( | $ | callback, |
| $ | expiry = false, |
||
| $ | extraData = null |
||
| ) |
Provides access to the file contents by downloading the file locally and calling $callback with the local filename. The callback can then process the contents and return the data in the same way as in processCache(). Downloading is only done once so the local copy is kept, while updates to the remote DB entry is synced with the local one.
The parameters $expiry and $extraData is the same as for processCache().
Definition at line 759 of file ezdbfilehandler.php.
| eZDBFileHandler::purge | ( | $ | printCallback = false, |
| $ | microsleep = false, |
||
| $ | max = false, |
||
| $ | expiry = false |
||
| ) |
Purge local and remote file data for current file.
Definition at line 1014 of file ezdbfilehandler.php.
| eZDBFileHandler::requiresBinaryPurge | ( | ) |
eZDB does require binary purge.
It does store files in DB and therefore doesn't remove files in real time
Definition at line 1329 of file ezdbfilehandler.php.
| eZDBFileHandler::requiresClusterizing | ( | ) |
Since eZDB uses the database, running clusterize.php is required.
Definition at line 1316 of file ezdbfilehandler.php.
| eZDBFileHandler::requiresPurge | ( | ) |
eZDB does require binary purge.
It does store files in DB and therefore doesn't remove files in real time
Definition at line 1341 of file ezdbfilehandler.php.
| eZDBFileHandler::size | ( | ) |
Returns file size.
Definition at line 856 of file ezdbfilehandler.php.
| eZDBFileHandler::startCacheGeneration | ( | ) |
Starts cache generation for the current file.
This is done by creating a file named by the original file name, prefixed with '.generating'.
Definition at line 1212 of file ezdbfilehandler.php.
Referenced by processCache().
| eZDBFileHandler::stat | ( | ) |
Returns file metadata.
Definition at line 843 of file ezdbfilehandler.php.
| eZDBFileHandler::storeCache | ( | $ | fileData | ) | [private] |
Stores the data in $fileData to the remote and local file and commits the transaction.
The parameter $fileData must contain the same as information as the $generateCallback returns as explained in processCache().
Definition at line 650 of file ezdbfilehandler.php.
Referenced by processCache().
| eZDBFileHandler::storeContents | ( | $ | contents, |
| $ | scope = false, |
||
| $ | datatype = false, |
||
| $ | storeLocally = false |
||
| ) |
Store file contents.
| $storeLocally | If true the file will also be stored on the local file system. |
Definition at line 189 of file ezdbfilehandler.php.
Referenced by storeCache().
| eZDBFileHandler::$backend |
Definition at line 1381 of file ezdbfilehandler.php.
| eZDBFileHandler::$backendVerify |
Definition at line 1388 of file ezdbfilehandler.php.
| eZDBFileHandler::$filePath |
Definition at line 1394 of file ezdbfilehandler.php.
Referenced by eZDBFileHandler(), fetch(), fetchContents(), fetchUnique(), fileFetch(), fileFetchContents(), fileStore(), fileStoreContents(), and storeContents().
eZDBFileHandler::$generationStartTimestamp = false [private] |
Definition at line 1444 of file ezdbfilehandler.php.
| eZDBFileHandler::$metaData = null |
holds the file's metaData loaded from database The variable's type indicates the exact status:
Definition at line 1416 of file ezdbfilehandler.php.
Referenced by fetch(), and loadMetaData().
eZDBFileHandler::$nonExistantStaleCacheHandling [private] |
Holds the preferences used when stale cache is activated and no expired file is available.
This is loaded from file.ini, ClusteringSettings.NonExistantStaleCacheHandling
Definition at line 1430 of file ezdbfilehandler.php.
| eZDBFileHandler::$realFilePath = null |
holds the real file path.
This is only used when we are generating a cache file, in which case $filePath holds the generating cache file name, and $realFilePath holds the real name
Definition at line 1401 of file ezdbfilehandler.php.
eZDBFileHandler::$remainingCacheGenerationTime = false [private] |
Definition at line 1436 of file ezdbfilehandler.php.
eZDBFileHandler::$useStaleCache = false [private] |
Definition at line 1423 of file ezdbfilehandler.php.
| const eZDBFileHandler::INFOCACHE_MAX = 200 |
Controls the maximum number of metdata entries to keep in memory for this request. If the limit is reached the least used entries are removed.
Definition at line 48 of file ezdbfilehandler.php.
| const eZDBFileHandler::LOCAL_CACHE = 1 |
Controls whether file data from database is cached on the local filesystem.
Definition at line 42 of file ezdbfilehandler.php.