|
eZ Publish
[trunk]
|
Inheritance diagram for eZFSFileHandler:Public Member Functions | |
| 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 () | |
| Ends the cache generation started by startCacheGeneration(). | |
| exists () | |
| Check if given file/dir exists. | |
| eZFSFileHandler ($filePath=false) | |
| Constructor. | |
| fetch ($noLocalCache=false) | |
| Fetches file from db and saves it in FS under the same name. | |
| fetchContents () | |
| Returns file contents. | |
| fetchUnique () | |
| Fetches file from db and saves it in FS under unique name. | |
| fileDeleteLocal ($path) | |
| Deletes a file that has been fetched before. | |
| fileFetch ($filePath) | |
| Fetches file from db and saves it in FS under the same name. | |
| fileFetchContents ($filePath) | |
| Returns file contents. | |
| fileStore ($filePath, $scope=false, $delete=false, $datatype=false) | |
| Store file. | |
| hasStaleCacheSupport () | |
| isExpired ($expiry, $curtime, $ttl) | |
| Calculates if the current file data is expired or not. | |
| loadMetaData ($force=false) | |
| move ($dstPath) | |
| Move file. | |
| mtime () | |
| Returns file modification time. | |
| name () | |
| Returns file name. | |
| passthrough ($offset=0, $length=false) | |
| Outputs file contents to the browser Note: does not handle 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 () | |
| eZFS does not require binary purge. | |
| requiresClusterizing () | |
| eZFS only stores data to FS and doesn't require/support clusterizing | |
| requiresPurge () | |
| eZFS does not 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 to disk. | |
Static Public Member Functions | |
| delete () | |
| Deletes specified file/directory. | |
| fileCopy ($srcPath, $dstPath) | |
| Copy file. | |
| fileDelete ($path, $fnamePart=false) | |
| fileDeleteByDirList ($dirList, $commonPath, $commonSuffix) | |
| Delete files located in a directories from dirList, with common prefix specified by commonPath, and common suffix with added wildcard at the end. | |
| fileDeleteByRegex ($dir, $fileRegex) | |
| Delete files matching regex $fileRegex under directory $dir. | |
| fileDeleteByWildcard ($wildcard) | |
| Delete files matching given wildcard. | |
| fileExists ($path) | |
| Check if given file/dir exists. | |
| fileLinkCopy ($srcPath, $dstPath, $symLink) | |
| Create symbolic or hard link to file. | |
| fileMove ($srcPath, $dstPath) | |
| Move file. | |
| fileStoreContents ($filePath, $contents, $scope=false, $datatype=false) | |
| Store file contents. | |
| static | isFileExpired ($fname, $mtime, $expiry, $curtime, $ttl) |
| Calculates if the file data is expired or not. | |
Public Attributes | |
| $filePath | |
| $metaData = null | |
| const | EXPIRY_TIMESTAMP = 233366400 |
| This should be defined in eZFS2FileHandler, but due to static members limitations in PHP < 5.3, it is declared here. | |
Private Member Functions | |
| _exclusiveLock ($fname=false) | |
| _freeExclusiveLock ($fname=false) | |
| & | _mutex () |
| storeCache ($fileData, $storeCache=true) | |
Definition at line 11 of file ezfsfilehandler.php.
| eZFSFileHandler::_exclusiveLock | ( | $ | fname = false | ) | [private] |
Acquires an exclusive lock to the current file by using eZMutex.
If a lock is already present it will sleep 0.5 seconds and try again until the lock lifetime is exceeded and the lock is stolen.
Note: Lock stealing might be removed.
| $fname | Name of the calling code (usually function name). |
Definition at line 44 of file ezfsfilehandler.php.
Referenced by processCache().
| eZFSFileHandler::_freeExclusiveLock | ( | $ | fname = false | ) | [private] |
Frees the current exclusive lock in use.
| $fname | Name of the calling code (usually function name). |
Definition at line 89 of file ezfsfilehandler.php.
Referenced by processCache(), and storeCache().
| & eZFSFileHandler::_mutex | ( | ) | [private] |
Returns the mutex object for the current file.
Definition at line 99 of file ezfsfilehandler.php.
Referenced by _exclusiveLock(), and _freeExclusiveLock().
Aborts the current cache generation process.
Does so by rolling back the current transaction, which should be the .generating file lock
Reimplemented in eZFS2FileHandler.
Definition at line 996 of file ezfsfilehandler.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
Reimplemented in eZFS2FileHandler.
Definition at line 1006 of file ezfsfilehandler.php.
| eZFSFileHandler::delete | ( | ) | [static] |
Deletes specified file/directory.
If a directory specified it is deleted recursively.
Reimplemented in eZFS2FileHandler.
Definition at line 746 of file ezfsfilehandler.php.
Deletes a file that has been fetched before.
In case of fetching from filesystem does nothing.
Reimplemented in eZFS2FileHandler.
Definition at line 792 of file ezfsfilehandler.php.
Ends the cache generation started by startCacheGeneration().
Definition at line 985 of file ezfsfilehandler.php.
Referenced by eZFS2FileHandler\storeCache().
Check if given file/dir exists.
NOTE: this function does not interact with filesystem. Instead, it just returns existance status determined in the constructor.
Reimplemented in eZFS2FileHandler.
Definition at line 880 of file ezfsfilehandler.php.
| eZFSFileHandler::eZFSFileHandler | ( | $ | filePath = false | ) |
Constructor.
$filePath File path. If specified, file metadata is fetched in the constructor.
Definition at line 24 of file ezfsfilehandler.php.
| eZFSFileHandler::fetch | ( | $ | noLocalCache = false | ) |
Fetches file from db and saves it in FS under the same name.
In case of fetching from filesystem does nothing.
Definition at line 145 of file ezfsfilehandler.php.
Returns file contents.
Definition at line 245 of file ezfsfilehandler.php.
Fetches file from db and saves it in FS under unique name.
In case of fetching from filesystem, does nothing
Definition at line 158 of file ezfsfilehandler.php.
| eZFSFileHandler::fileCopy | ( | $ | srcPath, |
| $ | dstPath | ||
| ) | [static] |
Copy file.
Definition at line 911 of file ezfsfilehandler.php.
| eZFSFileHandler::fileDelete | ( | $ | path, |
| $ | fnamePart = false |
||
| ) | [static] |
Reimplemented in eZFS2FileHandler.
Definition at line 700 of file ezfsfilehandler.php.
| eZFSFileHandler::fileDeleteByDirList | ( | $ | dirList, |
| $ | commonPath, | ||
| $ | commonSuffix | ||
| ) | [static] |
Delete files located in a directories from dirList, with common prefix specified by commonPath, and common suffix with added wildcard at the end.
Reimplemented in eZFS2FileHandler.
Definition at line 680 of file ezfsfilehandler.php.
| eZFSFileHandler::fileDeleteByRegex | ( | $ | dir, |
| $ | fileRegex | ||
| ) | [static] |
Delete files matching regex $fileRegex under directory $dir.
Definition at line 607 of file ezfsfilehandler.php.
| eZFSFileHandler::fileDeleteByWildcard | ( | $ | wildcard | ) | [static] |
Delete files matching given wildcard.
Note that this method is faster than fileDeleteByRegex().
Definition at line 658 of file ezfsfilehandler.php.
| eZFSFileHandler::fileDeleteLocal | ( | $ | path | ) |
Deletes a file that has been fetched before.
In case of fetching from filesystem does nothing.
Definition at line 780 of file ezfsfilehandler.php.
| eZFSFileHandler::fileExists | ( | $ | path | ) | [static] |
Check if given file/dir exists.
Reimplemented in eZFS2FileHandler.
Definition at line 861 of file ezfsfilehandler.php.
| eZFSFileHandler::fileFetch | ( | $ | filePath | ) |
Fetches file from db and saves it in FS under the same name.
In case of fetching from filesystem does nothing.
Definition at line 134 of file ezfsfilehandler.php.
| eZFSFileHandler::fileFetchContents | ( | $ | filePath | ) |
Returns file contents.
Definition at line 228 of file ezfsfilehandler.php.
| eZFSFileHandler::fileLinkCopy | ( | $ | srcPath, |
| $ | dstPath, | ||
| $ | symLink | ||
| ) | [static] |
Create symbolic or hard link to file.
Definition at line 926 of file ezfsfilehandler.php.
| eZFSFileHandler::fileMove | ( | $ | srcPath, |
| $ | dstPath | ||
| ) | [static] |
Move file.
Definition at line 941 of file ezfsfilehandler.php.
| eZFSFileHandler::fileStore | ( | $ | filePath, |
| $ | scope = false, |
||
| $ | delete = false, |
||
| $ | datatype = false |
||
| ) |
Store file.
In case of storing to filesystem does nothing.
| string | $filePath | Path to the file being stored. |
| string | $scope | Means something like "file category". May be used to clean caches of a certain type. |
| string | $delete | true if the file should be deleted after storing. |
Definition at line 173 of file ezfsfilehandler.php.
| eZFSFileHandler::fileStoreContents | ( | $ | filePath, |
| $ | contents, | ||
| $ | scope = false, |
||
| $ | datatype = false |
||
| ) | [static] |
Store file contents.
Definition at line 184 of file ezfsfilehandler.php.
Reimplemented in eZFS2FileHandler.
Definition at line 1046 of file ezfsfilehandler.php.
| eZFSFileHandler::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 454 of file ezfsfilehandler.php.
Referenced by eZFS2FileHandler\processCache(), and processCache().
| static eZFSFileHandler::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 424 of file ezfsfilehandler.php.
Referenced by isExpired().
| eZFSFileHandler::loadMetaData | ( | $ | force = false | ) |
Load file meta information.
| $force | If true, file stats will be refreshed |
Definition at line 113 of file ezfsfilehandler.php.
Referenced by delete(), eZFS2FileHandler\endCacheGeneration(), eZFSFileHandler(), and eZFS2FileHandler\processCache().
| eZFSFileHandler::move | ( | $ | dstPath | ) |
Returns file modification time.
Definition at line 582 of file ezfsfilehandler.php.
Returns file name.
Definition at line 594 of file ezfsfilehandler.php.
| eZFSFileHandler::passthrough | ( | $ | offset = 0, |
| $ | length = false |
||
| ) |
Outputs file contents to the browser Note: does not handle headers.
eZFile::downloadHeaders() can be used for this
| int | $offset | Transfer start offset |
| int | $length | Transfer length, in bytes |
Definition at line 895 of file ezfsfilehandler.php.
| eZFSFileHandler::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.
Reimplemented in eZFS2FileHandler.
Definition at line 302 of file ezfsfilehandler.php.
Referenced by processFile().
| eZFSFileHandler::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 544 of file ezfsfilehandler.php.
| eZFSFileHandler::purge | ( | $ | printCallback = false, |
| $ | microsleep = false, |
||
| $ | max = false, |
||
| $ | expiry = false |
||
| ) |
Purge local and remote file data for current file.
Reimplemented in eZFS2FileHandler.
Definition at line 801 of file ezfsfilehandler.php.
eZFS does not require binary purge.
Files are stored on plain FS and removed using FS functions
Reimplemented in eZFS2FileHandler.
Definition at line 1029 of file ezfsfilehandler.php.
eZFS only stores data to FS and doesn't require/support clusterizing
Reimplemented in eZFS2FileHandler.
Definition at line 1016 of file ezfsfilehandler.php.
eZFS does not require binary purge.
Files are stored on plain FS and removed using FS functions
Reimplemented in eZFS2FileHandler.
Definition at line 1041 of file ezfsfilehandler.php.
Returns file size.
Definition at line 570 of file ezfsfilehandler.php.
Starts cache generation for the current file.
This is done by creating a file named by the original file name, prefixed with '.generating'.
Reimplemented in eZFS2FileHandler.
Definition at line 977 of file ezfsfilehandler.php.
Returns file metadata.
Definition at line 559 of file ezfsfilehandler.php.
Referenced by loadMetaData().
| eZFSFileHandler::storeCache | ( | $ | fileData, |
| $ | storeCache = true |
||
| ) | [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().
Reimplemented in eZFS2FileHandler.
Definition at line 472 of file ezfsfilehandler.php.
Referenced by processCache().
| eZFSFileHandler::storeContents | ( | $ | contents, |
| $ | scope = false, |
||
| $ | datatype = false, |
||
| $ | storeLocally = false |
||
| ) |
Store file contents to disk.
| string | $contents | Binary file data |
| string | $datatype | Not used in the FS handler |
| string | $scope | Not used in the FS handler |
| bool | $storeLocally | Not used in the FS handler |
Definition at line 208 of file ezfsfilehandler.php.
Referenced by eZFS2FileHandler\storeCache(), and storeCache().
| eZFSFileHandler::$filePath |
Definition at line 1052 of file ezfsfilehandler.php.
Referenced by eZFS2FileHandler\__construct(), eZFSFileHandler(), fetch(), fetchContents(), fileFetch(), fileFetchContents(), fileStoreContents(), eZFS2FileHandler\remainingCacheGenerationTime(), and storeContents().
| eZFSFileHandler::$metaData = null |
Definition at line 1051 of file ezfsfilehandler.php.
| const eZFSFileHandler::EXPIRY_TIMESTAMP = 233366400 |
This should be defined in eZFS2FileHandler, but due to static members limitations in PHP < 5.3, it is declared here.
Definition at line 17 of file ezfsfilehandler.php.
Referenced by eZFS2FileHandler\exists(), and eZFS2FileHandler\fileExists().