eZPublish  4.5
eZClusterFileHandlerInterface Interface Reference

Cluster file handlers interface. More...

+ Inheritance diagram for eZClusterFileHandlerInterface:

Public Member Functions

 abortCacheGeneration ()
 Aborts the current cache generation process. More...
 
 checkCacheGenerationTimeout ()
 Checks if the .generating file was changed, which would mean that generation timed out. More...
 
 delete ()
 Deletes specified file/directory. More...
 
 deleteLocal ()
 Deletes a file that has been fetched before. More...
 
 endCacheGeneration ($rename=true)
 Ends the cache generation started by startCacheGeneration(). More...
 
 exists ()
 Check if given file/dir exists. More...
 
 fetch ($noLocalCache=false)
 Fetches file from db and saves it in FS under the same name. More...
 
 fetchContents ()
 Returns file contents. More...
 
 fetchUnique ()
 Fetches a cluster file and saves it locally under a new name. More...
 
 fileCopy ($srcPath, $dstPath)
 Copy file. More...
 
 fileDelete ($path, $fnamePart=false)
 Deletes specified file/directory. More...
 
 fileDeleteByDirList ($dirList, $commonPath, $commonSuffix)
 
 fileDeleteByRegex ($dir, $fileRegex)
 
 fileDeleteByWildcard ($wildcard)
 
 fileDeleteLocal ($path)
 Deletes a file that has been fetched before. More...
 
 fileExists ($path)
 Check if given file/dir exists. More...
 
 fileFetch ($filePath)
 Fetches a file locally. More...
 
 fileFetchContents ($filePath)
 Returns file contents. More...
 
 fileLinkCopy ($srcPath, $dstPath, $symLink)
 Create symbolic or hard link to file. More...
 
 fileMove ($srcPath, $dstPath)
 Move file. More...
 
 fileStore ($filePath, $scope=false, $delete=false, $datatype=false)
 Stores a file by path to the backend. More...
 
 fileStoreContents ($filePath, $contents, $scope=false, $datatype=false)
 Store file contents. More...
 
 getFileList ($scopes=false, $excludeScopes=false)
 Get list of files stored in database. More...
 
 isDBFileExpired ($expiry, $curtime, $ttl)
 Calculates if the DB file is expired or not. More...
 
 isExpired ($expiry, $curtime, $ttl)
 Calculates if the current file data is expired or not. More...
 
 isFileExpired ($fname, $mtime, $expiry, $curtime, $ttl)
 Calculates if the file data is expired or not. More...
 
 isLocalFileExpired ($expiry, $curtime, $ttl)
 Calculates if the local file is expired or not. More...
 
 move ($dstPath)
 Move file. More...
 
 mtime ()
 Returns file modification time. More...
 
 name ()
 Returns file name. More...
 
 passthrough ()
 Outputs file contents prepending them with appropriate HTTP headers. More...
 
 processCache ($retrieveCallback, $generateCallback=null, $ttl=null, $expiry=null, $extraData=null)
 Handles cache requests / write operations. More...
 
 processFile ($callback, $expiry=false, $extraData=null)
 Provides access to the file contents by downloading the file locally and calling $callback with the local filename. More...
 
 purge ($printCallback=false, $microsleep=false, $max=false, $expiry=false)
 Purges local and remote file data for current file. More...
 
 requiresBinaryPurge ()
 This method indicates if the cluster file handler requires binary files to be purged in order to be physically deleted. More...
 
 requiresClusterizing ()
 This method indicates if the cluster file handler requires clusterizing. More...
 
 requiresPurge ()
 This method indicates if the cluster file handler requires binary files to be purged in order to be physically deleted. More...
 
 size ()
 Returns file size. More...
 
 startCacheGeneration ()
 Starts cache generation for the current file. More...
 
 stat ()
 Returns file metadata. More...
 
 storeContents ($contents, $scope=false, $datatype=false, $storeLocally=false)
 Store file contents using binary data. More...
 

Detailed Description

Cluster file handlers interface.

Member Function Documentation

eZClusterFileHandlerInterface::abortCacheGeneration ( )

Aborts the current cache generation process.

Does so by rolling back the current transaction, which should be the .generating file lock

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::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

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::delete ( )

Deletes specified file/directory.

If a directory specified it is deleted recursively.

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::deleteLocal ( )

Deletes a file that has been fetched before.

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::endCacheGeneration (   $rename = true)

Ends the cache generation started by startCacheGeneration().

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::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.
Returns
bool

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::fetch (   $noLocalCache = false)

Fetches file from db and saves it in FS under the same name.

Parameters
bool$noLocalCache

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::fetchContents ( )

Returns file contents.

Returns
string|bool contents string, or false in case of an error.

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::fetchUnique ( )

Fetches a cluster file and saves it locally under a new name.

Returns
string path to the saved file

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::fileCopy (   $srcPath,
  $dstPath 
)

Copy file.

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::fileDelete (   $path,
  $fnamePart = false 
)

Deletes specified file/directory.

If a directory specified it is deleted recursively.

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::fileDeleteByDirList (   $dirList,
  $commonPath,
  $commonSuffix 
)

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::fileDeleteByRegex (   $dir,
  $fileRegex 
)
Note
has severe performance issues

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::fileDeleteByWildcard (   $wildcard)
Note
has some severe performance issues

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::fileDeleteLocal (   $path)

Deletes a file that has been fetched before.

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::fileExists (   $path)

Check if given file/dir exists.

Parameters
string$file
Returns
bool

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::fileFetch (   $filePath)

Fetches a file locally.

Parameters
string$filePath
Returns
string|false the file path, or false if fetching failed

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::fileFetchContents (   $filePath)

Returns file contents.

Returns
contents string, or false in case of an error.

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::fileLinkCopy (   $srcPath,
  $dstPath,
  $symLink 
)

Create symbolic or hard link to file.

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::fileMove (   $srcPath,
  $dstPath 
)

Move file.

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::fileStore (   $filePath,
  $scope = false,
  $delete = false,
  $datatype = false 
)

Stores a file by path to the backend.

Parameters
string$filePathPath to the file being stored.
string$scopeMeans something like "file category". May be used to clean caches of a certain type.
bool$deletetrue if the file should be deleted after storing.
string$datatype
Returns
void

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::fileStoreContents (   $filePath,
  $contents,
  $scope = false,
  $datatype = false 
)

Store file contents.

Parameters
string$filePathPath to the file being stored.
string$contentsBinary file content
string$scope"file category". May be used by cache management
string$datatypeDatatype for the file. Also used to clean cache up
Returns
void

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::getFileList (   $scopes = false,
  $excludeScopes = false 
)

Get list of files stored in database.

Used in bin/php/clusterize.php.

Parameters
array$scopesreturn only files that belong to any of these scopes
boolean$excludeScopesif true, then reverse the meaning of $scopes, which is return only files that do not belong to any of the scopes listed in $scopes

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::isDBFileExpired (   $expiry,
  $curtime,
  $ttl 
)

Calculates if the DB file is expired or not.

Parameters
int$expiryTime when file is to be expired, a value of -1 will disable this check.
int$curtimeThe current time to check against.
int$ttlNumber of seconds the data can live, set to null to disable TTL.
Returns
bool

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::isExpired (   $expiry,
  $curtime,
  $ttl 
)

Calculates if the current file data is expired or not.

Parameters
int$expiryTime when file is to be expired, a value of -1 will disable this check.
int$curtimeThe current time to check against.
int$ttlNumber of seconds the data can live, set to null to disable TTL.
Returns
bool

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::isFileExpired (   $fname,
  $mtime,
  $expiry,
  $curtime,
  $ttl 
)

Calculates if the file data is expired or not.

Parameters
string$fnameName of file, available for easy debugging.
int$mtimeModification time of file, can be set to false if file does not exist.
int$expiryTime when file is to be expired, a value of -1 will disable this check.
int$curtimeThe current time to check against.
int$ttlNumber of seconds the data can live, set to null to disable TTL.
Returns
bool

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::isLocalFileExpired (   $expiry,
  $curtime,
  $ttl 
)

Calculates if the local file is expired or not.

Parameters
int$expiryTime when file is to be expired, a value of -1 will disable this check.
int$curtimeThe current time to check against.
int$ttlNumber of seconds the data can live, set to null to disable TTL.
Returns
bool

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::move (   $dstPath)

Move file.

Parameters
string$dstPathDestination path

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::mtime ( )

Returns file modification time.

Returns
int|null

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::name ( )

Returns file name.

Returns
string

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::passthrough ( )

Outputs file contents prepending them with appropriate HTTP headers.

Deprecated:
This function should not be used since it cannot handle reading errors.

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::processCache (   $retrieveCallback,
  $generateCallback = null,
  $ttl = null,
  $expiry = null,
  $extraData = null 
)

Handles cache requests / write operations.

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:

  • scope - The current scope of the file, is optional.
  • datatype - The current datatype of the file, is optional.
  • content - The file content, this can be any type except null.
  • binarydata - The binary data which is written to the file.
  • store - Whether content or binarydata should be stored to the file, if false it will simply return the data. Optional, by default it is true. Note: Set $generateCallback to false to disable generation callback. Note: Set $generateCallback 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
    See Also
    storeCache().
    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

See Also
$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.

Todo:
Reformat the doc so that it's readable

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::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().

See Also
self::processCache()
Note
Unlike processCache() this returns null if the file cannot be accessed.

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::purge (   $printCallback = false,
  $microsleep = false,
  $max = false,
  $expiry = false 
)

Purges local and remote file data for current file.

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::requiresBinaryPurge ( )

This method indicates if the cluster file handler requires binary files to be purged in order to be physically deleted.

Since
4.3
Deprecated:
Deprecated as of 4.5, use eZClusterFileHandlerInterface::requiresPurge() instead.
Returns
bool

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::requiresClusterizing ( )

This method indicates if the cluster file handler requires clusterizing.

If the handler does require clusterizing, it will be required/possible to use bin/php/clusterize.php to get data in/out of the cluster when setting it up or disabling it.

Returns
bool

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::requiresPurge ( )

This method indicates if the cluster file handler requires binary files to be purged in order to be physically deleted.

Since
4.5
Returns
bool

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::size ( )

Returns file size.

Returns
int|null

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::startCacheGeneration ( )

Starts cache generation for the current file.

This is done by creating a file named by the original file name, prefixed with '.generating'.

Returns
bool false if the file is being generated, true if it is not

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::stat ( )

Returns file metadata.

Implemented in eZDFSFileHandler.

eZClusterFileHandlerInterface::storeContents (   $contents,
  $scope = false,
  $datatype = false,
  $storeLocally = false 
)

Store file contents using binary data.

Parameters
string$contentsBinary file content
string$scope"file category". May be used by cache management
string$datatypeDatatype for the file. Also used to clean cache up
bool$storeLocallyIf true the file will also be stored on the local file system.

Implemented in eZDFSFileHandler.


The documentation for this interface was generated from the following file: