Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

Public Member Functions | Static Public Member Functions | List of all members
eZClusterFileHandlerInterface Interface Reference
Inheritance diagram for eZClusterFileHandlerInterface:

## Public Member Functions
| fileStore ( $filePath, $scope=false, $delete=false, $datatype=false)
| fileStoreContents ( $filePath, $contents, $scope=false, $datatype=false)
| storeContents ( $contents, $scope=false, $datatype=false, $storeLocally=false)
| fileFetch ( $filePath)
| processCache ( $retrieveCallback, $generateCallback=null, $ttl=null, $expiry=null, $extraData=null)
| isExpired ( $expiry, $curtime, $ttl)
| isLocalFileExpired ( $expiry, $curtime, $ttl)
| isDBFileExpired ( $expiry, $curtime, $ttl)
| processFile ( $callback, $expiry=false, $extraData=null)
| fetchUnique ()
| fetch ( $noLocalCache=false)
| fileFetchContents ( $filePath)
| fetchContents ()
| loadMetaData ( $force=false)
| stat ()
| size ()
| mtime ()
| dataType ()
| name ()
| fileDeleteByWildcard ( $wildcard)
| fileDeleteByDirList ( $dirList, $commonPath, $commonSuffix)
| fileDelete ( $path, $fnamePart=false)
| delete ()
| fileDeleteLocal ( $path)
| deleteLocal ()
| purge ( $printCallback=false, $microsleep=false, $max=false, $expiry=false)
| fileExists ( $path)
| exists ()
| passthrough ()
| fileCopy ( $srcPath, $dstPath)
| fileLinkCopy ( $srcPath, $dstPath, $symLink)
| fileMove ( $srcPath, $dstPath)
| move ( $dstPath)
| getFileList ( $scopes=false, $excludeScopes=false)
| storeCache ( $fileData)
| startCacheGeneration ()
| endCacheGeneration ( $rename=true)
| abortCacheGeneration ()
| checkCacheGenerationTimeout ()
| requiresClusterizing ()
| requiresPurge ()
| hasStaleCacheSupport ()
| applyServerUri ( $filePath)

## Static Public Member Functions
static | isFileExpired ( $fname, $mtime, $expiry, $curtime, $ttl)

## Detailed Description

Cluster file handlers interface

Definition at line 15 of file ezclusterfilehandlerinterface.php.

## Member Function Documentation

## ◆ abortCacheGeneration()

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, and eZFSFileHandler.

## ◆ applyServerUri()

eZClusterFileHandlerInterface::applyServerUri | ( |  | $filePath | ) |

Transforms $filePath so that it contains a valid href to the file, wherever it is stored.

Parameters

  string | $filePath | Example: /var/site/storage/images/example.png

Returns
  string http://static.example.com/var/site/storage/images/example.png

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ checkCacheGenerationTimeout()

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, and eZFSFileHandler.

## ◆ dataType()

eZClusterFileHandlerInterface::dataType | ( |  | ) |

Returns file mimetype / content type.

Returns
  string|null

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ delete()

eZClusterFileHandlerInterface::delete | ( |  | ) |

Deletes specified file/directory.

If a directory specified it is deleted recursively.

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ deleteLocal()

eZClusterFileHandlerInterface::deleteLocal | ( |  | ) |

Deletes a file that has been fetched before.

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ endCacheGeneration()

eZClusterFileHandlerInterface::endCacheGeneration | ( |  | $rename = `true` | ) |

Ends the cache generation started by startCacheGeneration().

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ exists()

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 eZFSFileHandler.

## ◆ fetch()

eZClusterFileHandlerInterface::fetch | ( |  | $noLocalCache = `false` | ) |

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

Parameters

  bool | $noLocalCache |

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ fetchContents()

eZClusterFileHandlerInterface::fetchContents | ( |  | ) |

Returns file contents.

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

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ fetchUnique()

eZClusterFileHandlerInterface::fetchUnique | ( |  | ) |

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

Returns
  string path to the saved file

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ fileCopy()

eZClusterFileHandlerInterface::fileCopy | ( |  | $srcPath,
|  |  | $dstPath
| ) |  |

Copy file.

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ fileDelete()

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

Deletes specified file/directory.

If a directory specified it is deleted recursively.

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ fileDeleteByDirList()

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

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ fileDeleteByWildcard()

eZClusterFileHandlerInterface::fileDeleteByWildcard | ( |  | $wildcard | ) |

Note
  has some severe performance issues

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ fileDeleteLocal()

eZClusterFileHandlerInterface::fileDeleteLocal | ( |  | $path | ) |

Deletes a file that has been fetched before.

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ fileExists()

eZClusterFileHandlerInterface::fileExists | ( |  | $path | ) |

Check if given file/dir exists.

Parameters

  string | $file |

Returns
  bool

Implemented in eZFSFileHandler.

## ◆ fileFetch()

eZClusterFileHandlerInterface::fileFetch | ( |  | $filePath | ) |

Fetches a file locally

Parameters

  string | $filePath |

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

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ fileFetchContents()

eZClusterFileHandlerInterface::fileFetchContents | ( |  | $filePath | ) |

Returns file contents.

Parameters

  string | $filePath |

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

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ fileLinkCopy()

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

Create symbolic or hard link to file.

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ fileMove()

eZClusterFileHandlerInterface::fileMove | ( |  | $srcPath,
|  |  | $dstPath
| ) |  |

Move file.

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ fileStore()

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

Stores a file by path to the backend

Parameters

  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.
  bool | $delete | true if the file should be deleted after storing.
  string | $datatype |

Returns
  void

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ fileStoreContents()

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

Store file contents.

Parameters

  string | $filePath | Path to the file being stored.
  string | $contents | Binary file content
  string | $scope | "file category". May be used by cache management
  string | $datatype | Datatype for the file. Also used to clean cache up

Returns
  void

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ getFileList()

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

Get list of files stored in database.

Used in bin/php/clusterize.php.

Parameters

  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

Implemented in eZFSFileHandler.

## ◆ hasStaleCacheSupport()

eZClusterFileHandlerInterface::hasStaleCacheSupport | ( |  | ) |

Indicates if the handler supports the stalecache feature

Returns
  bool true if it does, false otherwise

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ isDBFileExpired()

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

Calculates if the DB file is expired or not.

Parameters

  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.

Returns
  bool

Implemented in eZFSFileHandler, and eZDFSFileHandler.

## ◆ isExpired()

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

Calculates if the current file data is expired or not.

Parameters

  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.

Returns
  bool

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ isFileExpired()

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

Calculates if the file data is expired or not.

Parameters

  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.

Returns
  bool

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ isLocalFileExpired()

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

Calculates if the local file is expired or not.

Parameters

  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.

Returns
  bool

Implemented in eZFSFileHandler, and eZDFSFileHandler.

## ◆ loadMetaData()

eZClusterFileHandlerInterface::loadMetaData | ( |  | $force = `false` | ) |

Loads file meta information.

Parameters

  bool | $force | File stats will be refreshed if true

Returns
  void

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ move()

eZClusterFileHandlerInterface::move | ( |  | $dstPath | ) |

Move file.

Parameters

  string | $dstPath | Destination path

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ mtime()

eZClusterFileHandlerInterface::mtime | ( |  | ) |

Returns file modification time.

Returns
  int|null

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ name()

eZClusterFileHandlerInterface::name | ( |  | ) |

Returns file name.

Returns
  string

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ passthrough()

eZClusterFileHandlerInterface::passthrough | ( |  | ) |

Outputs file contents prepending them with appropriate HTTP headers.

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

## ◆ processCache()

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, and eZFSFileHandler.

## ◆ processFile()

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, and eZFSFileHandler.

## ◆ purge()

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

Purges local and remote file data for current file.

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ requiresClusterizing()

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, and eZFSFileHandler.

## ◆ requiresPurge()

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, and eZFSFileHandler.

## ◆ size()

eZClusterFileHandlerInterface::size | ( |  | ) |

Returns file size.

Returns
  int|null

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ startCacheGeneration()

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, and eZFSFileHandler.

## ◆ stat()

eZClusterFileHandlerInterface::stat | ( |  | ) |

Returns file metadata.

Implemented in eZDFSFileHandler, and eZFSFileHandler.

## ◆ storeCache()

eZClusterFileHandlerInterface::storeCache | ( |  | $fileData | ) |

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

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.

Parameters

  string | array | $fileData |

Returns
  string|null

Implemented in eZDFSFileHandler.

## ◆ storeContents()

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

Store file contents using binary data

Parameters

  string | $contents | Binary file content
  string | $scope | "file category". May be used by cache management
  string | $datatype | Datatype for the file. Also used to clean cache up
  bool | $storeLocally | If true the file will also be stored on the local file system.

Implemented in eZDFSFileHandler, and eZFSFileHandler.

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

- ezclusterfilehandlerinterface.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.