|
eZ Publish
[trunk]
|
Inheritance diagram for eZDBFileHandler:
Collaboration diagram for eZDBFileHandler:Public Member Functions | |
| __construct ($filePath=false) | |
| Constructor. | |
| __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. | |
| disconnect () | |
| Disconnects the cluster handler from the database. | |
| endCacheGeneration ($rename=true) | |
| Ends the cache generation started by startCacheGeneration(). | |
| exists () | |
| Check if given file/dir exists. | |
| 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. | |
| fetchUnique () | |
| Fetches file from db and saves it in FS under unique name. | |
| fileStore ($filePath, $scope=false, $delete=false, $datatype=false) | |
| Stores a local file to the cluster. | |
| fileStoreContents ($filePath, $contents, $scope=false, $datatype=false) | |
| Store file contents. | |
| getFileList ($scopes=false, $excludeScopes=false) | |
| Get list of files stored in database. | |
| hasStaleCacheSupport () | |
| 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) | |
| Load file meta information from the database. | |
| move ($dstPath) | |
| Move file. | |
| mtime () | |
| Returns file modification time. | |
| name () | |
| Returns file name. | |
| passthrough ($offset=0, $length=false) | |
| Outputs file contents prepending them with appropriate HTTP headers. | |
| processCache ($retrieveCallback, $generateCallback=null, $ttl=null, $expiry=null, $extraData=null) | |
| Creates a single transaction out of the typical file operations for accessing caches. | |
| 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. | |
| storeCache ($fileData) | |
| Stores the data in $fileData to the remote and local file and commits the transaction. | |
| 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. | |
| 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. | |
| static | isFileExpired ($fname, $mtime, $expiry, $curtime, $ttl) |
| Calculates if the file data is expired or not. | |
Public Attributes | |
| $_metaData = null | |
| holds the file's metaData loaded from database The variable's type indicates the exact status: | |
| $filePath | |
| $realFilePath = null | |
| holds the real file path. | |
| const | INFOCACHE_MAX = 200 |
| const | LOCAL_CACHE = 1 |
Static Public Attributes | |
| static | $dbbackend |
Protected Member Functions | |
| computeCacheType () | |
| Determines the cache type based on the path. | |
| fixPermissions ($filePath) | |
Protected Attributes | |
| $_cacheType | |
| $generationStartTimestamp = false | |
| $nonExistantStaleCacheHandling | |
| Holds the preferences used when stale cache is activated and no expired file is available. | |
| $remainingCacheGenerationTime = false | |
| $useStaleCache = false | |
Private Attributes | |
| $filePermissionMask | |
Note: Not all code is using this class for cluster access, see index_image_mysql.php and index_image_pgsql.php for more custom code.
Definition at line 15 of file ezdbfilehandler.php.
| eZDBFileHandler::__construct | ( | $ | filePath = false | ) |
Constructor.
$filePath File path. If specified, file metadata is fetched in the constructor.
Definition at line 34 of file ezdbfilehandler.php.
| eZDBFileHandler::__get | ( | $ | propertyName | ) |
Magic getter.
Definition at line 1294 of file ezdbfilehandler.php.
Aborts the current cache generation process.
Does so by rolling back the current transaction, which should be the .generating file lock
Definition at line 1259 of file ezdbfilehandler.php.
Referenced by storeCache().
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 1272 of file ezdbfilehandler.php.
Referenced by storeCache().
| static eZDBFileHandler::cleanPath | ( | $ | path | ) | [static] |
Returns a clean version of input $path.
Examples:
Definition at line 1191 of file ezdbfilehandler.php.
Referenced by __construct(), fileCopy(), fileDelete(), fileDeleteByDirList(), fileDeleteByRegex(), fileDeleteByWildcard(), fileDeleteLocal(), eZDFSFileHandler\fileDeleteLocal(), fileExists(), fileFetch(), fileFetchContents(), fileLinkCopy(), fileMove(), fileStore(), fileStoreContents(), and move().
| eZDBFileHandler::computeCacheType | ( | ) | [protected] |
Determines the cache type based on the path.
Definition at line 1281 of file ezdbfilehandler.php.
Referenced by __get().
| eZDBFileHandler::delete | ( | ) | [static] |
Deletes specified file/directory.
If a directory specified it is deleted recursively.
Definition at line 977 of file ezdbfilehandler.php.
Deletes a file that has been fetched before.
Definition at line 1008 of file ezdbfilehandler.php.
Disconnects the cluster handler from the database.
Implements ezpDatabaseBasedClusterFileHandler.
Definition at line 70 of file ezdbfilehandler.php.
| eZDBFileHandler::endCacheGeneration | ( | $ | rename = true | ) |
Ends the cache generation started by startCacheGeneration().
Definition at line 1238 of file ezdbfilehandler.php.
Referenced by storeCache().
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 1072 of file ezdbfilehandler.php.
| eZDBFileHandler::fetch | ( | $ | noLocalCache = false | ) |
Fetches file from db and saves it in FS under the same name.
Definition at line 794 of file ezdbfilehandler.php.
Referenced by processCache().
Returns file contents.
Definition at line 835 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 1362 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 1377 of file ezdbfilehandler.php.
Fetches file from db and saves it in FS under unique name.
Definition at line 779 of file ezdbfilehandler.php.
Referenced by processCache().
| eZDBFileHandler::fileCopy | ( | $ | srcPath, |
| $ | dstPath | ||
| ) | [static] |
Copy file.
Definition at line 1104 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 952 of file ezdbfilehandler.php.
| eZDBFileHandler::fileDeleteByDirList | ( | $ | dirList, |
| $ | commonPath, | ||
| $ | commonSuffix | ||
| ) | [static] |
Definition at line 930 of file ezdbfilehandler.php.
| eZDBFileHandler::fileDeleteByRegex | ( | $ | dir, |
| $ | fileRegex | ||
| ) | [static] |
Definition at line 901 of file ezdbfilehandler.php.
| eZDBFileHandler::fileDeleteByWildcard | ( | $ | wildcard | ) | [static] |
Definition at line 917 of file ezdbfilehandler.php.
| eZDBFileHandler::fileDeleteLocal | ( | $ | path | ) | [static] |
Deletes a file that has been fetched before.
Definition at line 993 of file ezdbfilehandler.php.
Referenced by processCache().
| eZDBFileHandler::fileExists | ( | $ | path | ) | [static] |
Check if given file/dir exists.
Definition at line 1055 of file ezdbfilehandler.php.
| eZDBFileHandler::fileFetch | ( | $ | filePath | ) | [static] |
Fetches file from db and saves it in FS under the same name.
Definition at line 206 of file ezdbfilehandler.php.
| eZDBFileHandler::fileFetchContents | ( | $ | filePath | ) | [static] |
Returns file contents.
Definition at line 820 of file ezdbfilehandler.php.
| eZDBFileHandler::fileLinkCopy | ( | $ | srcPath, |
| $ | dstPath, | ||
| $ | symLink | ||
| ) | [static] |
Create symbolic or hard link to file.
Definition at line 1119 of file ezdbfilehandler.php.
| eZDBFileHandler::fileMove | ( | $ | srcPath, |
| $ | dstPath | ||
| ) | [static] |
Move file.
Definition at line 1134 of file ezdbfilehandler.php.
| eZDBFileHandler::fileStore | ( | $ | filePath, |
| $ | scope = false, |
||
| $ | delete = false, |
||
| $ | datatype = false |
||
| ) |
Stores a local file to the cluster.
| string | $filePath | Path to the file being stored. |
| string | $scope | File scope. Used to group similar files together. Examples: image, template-block... |
| string | $delete | true if the file should be deleted after storing. |
| string | $datatype | File mime type |
Definition at line 135 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 162 of file ezdbfilehandler.php.
| eZDBFileHandler::fixPermissions | ( | $ | filePath | ) | [protected] |
Definition at line 1387 of file ezdbfilehandler.php.
Referenced by fetch(), and fileFetch().
| 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 1171 of file ezdbfilehandler.php.
Definition at line 1382 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 640 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 613 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 587 of file ezdbfilehandler.php.
Referenced by eZDBFileHandlerMysqlBackend\_verifyExclusiveLock(), eZDBFileHandlerMysqliBackend\_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 628 of file ezdbfilehandler.php.
Referenced by processCache().
| eZDBFileHandler::loadMetaData | ( | $ | force = false | ) |
Load file meta information from the database.
| bool | $force | File stats will be refreshed if true |
Definition at line 80 of file ezdbfilehandler.php.
Referenced by __get(), isExpired(), mtime(), passthrough(), processCache(), size(), and stat().
| eZDBFileHandler::move | ( | $ | dstPath | ) |
Move file.
Definition at line 1150 of file ezdbfilehandler.php.
Returns file modification time.
Definition at line 875 of file ezdbfilehandler.php.
Returns file name.
Definition at line 889 of file ezdbfilehandler.php.
| eZDBFileHandler::passthrough | ( | $ | offset = 0, |
| $ | length = false |
||
| ) |
Outputs file contents prepending them with appropriate HTTP headers.
| int | $offset | Transfer start offset |
| int | $length | Transfer length |
Definition at line 1088 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.
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 controlling how long a cache entry can be used the parameters $expiry and $ttl is used.
| mixed | $retrieveCallback | 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. Set to null to tell the function to perform a write lock but not do any generation, the generation must done be done by the caller by calling storeCache(). |
| mixed | $generateCallback | 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. Set to false to disable generation callback. 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. |
| mixed | $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. |
| mixed | $expiry | $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. |
| mixed | $extraData | Extra parameters to be sent to $generateCallback and $retrieveCallback |
Definition at line 268 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 764 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 1020 of file ezdbfilehandler.php.
eZDB does require binary purge.
It does store files in DB and therefore doesn't remove files in real time
Definition at line 1334 of file ezdbfilehandler.php.
Since eZDB uses the database, running clusterize.php is required.
Definition at line 1321 of file ezdbfilehandler.php.
eZDB does require binary purge.
It does store files in DB and therefore doesn't remove files in real time
Definition at line 1346 of file ezdbfilehandler.php.
Returns file size.
Definition at line 861 of file ezdbfilehandler.php.
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 1208 of file ezdbfilehandler.php.
Referenced by processCache().
Returns file metadata.
Definition at line 848 of file ezdbfilehandler.php.
| eZDBFileHandler::storeCache | ( | $ | fileData | ) |
Stores the data in $fileData to the remote and local file and commits the transaction.
This method is just a continuation of the code in processCache() and is not meant to be called alone since it relies on specific state in the database.
The parameter $fileData must contain the same as information as the $generateCallback returns as explained in processCache().
Definition at line 655 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 183 of file ezdbfilehandler.php.
Referenced by storeCache().
eZDBFileHandler::$_cacheType [protected] |
Definition at line 1459 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 1425 of file ezdbfilehandler.php.
eZDBFileHandler::$dbbackend [static] |
Definition at line 1397 of file ezdbfilehandler.php.
| eZDBFileHandler::$filePath |
Definition at line 1403 of file ezdbfilehandler.php.
Referenced by __construct(), fetch(), fetchContents(), fetchUnique(), fileFetch(), fileFetchContents(), fileStore(), fileStoreContents(), fixPermissions(), and storeContents().
eZDBFileHandler::$filePermissionMask [private] |
Definition at line 1465 of file ezdbfilehandler.php.
eZDBFileHandler::$generationStartTimestamp = false [protected] |
Definition at line 1453 of file ezdbfilehandler.php.
eZDBFileHandler::$nonExistantStaleCacheHandling [protected] |
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 1439 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 1410 of file ezdbfilehandler.php.
eZDBFileHandler::$remainingCacheGenerationTime = false [protected] |
Definition at line 1445 of file ezdbfilehandler.php.
eZDBFileHandler::$useStaleCache = false [protected] |
Definition at line 1432 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 27 of file ezdbfilehandler.php.
| const eZDBFileHandler::LOCAL_CACHE = 1 |
Controls whether file data from database is cached on the local filesystem.
Definition at line 21 of file ezdbfilehandler.php.