kernel/private/interfaces/ezclusterfilehandlerinterface.php
File containing the eZClusterFileHandlerInterface interface.
- Copyright
- Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.
- License
- eZ Business Use License Agreement Version 2.0
- Package
- lib
- Version
- 4.6.0
\eZClusterFileHandlerInterface
Cluster file handlers interface
- Children
- \eZDFSFileHandler
Methods

abortCacheGeneration(
)
:
voidAborts the current cache generation process.
Does so by rolling back the current transaction, which should be the .generating file lock

checkCacheGenerationTimeout(
)
:
voidChecks 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

delete(
)
:
voidDeletes specified file/directory.
If a directory specified it is deleted recursively.

endCacheGeneration(
$rename
=
true
)
:
voidEnds the cache generation started by startCacheGeneration().
| Name | Type | Description |
|---|---|---|
| $rename |

exists(
)
:
boolCheck if given file/dir exists.
| Type | Description |
|---|---|
| bool |
- Note
- This function does not interact with database. Instead, it just returns existance status determined in the constructor.

fetch(
bool $noLocalCache
=
false
)
:
voidFetches file from db and saves it in FS under the same name.
| Name | Type | Description |
|---|---|---|
| $noLocalCache | bool |

fetchContents(
)
:
string | boolReturns file contents.
| Type | Description |
|---|---|
| string | bool | contents string, or false in case of an error. |

fetchUnique(
)
:
stringFetches a cluster file and saves it locally under a new name
| Type | Description |
|---|---|
| string | path to the saved file |

fileDelete(
$path, $fnamePart
=
false
)
:
voidDeletes specified file/directory.
If a directory specified it is deleted recursively.
| Name | Type | Description |
|---|---|---|
| $path | ||
| $fnamePart |

fileDeleteByDirList(
$dirList, $commonPath, $commonSuffix
)
:
void| Name | Type | Description |
|---|---|---|
| $dirList | ||
| $commonPath | ||
| $commonSuffix |

fileDeleteByRegex(
$dir, $fileRegex
)
:
void| Name | Type | Description |
|---|---|---|
| $dir | ||
| $fileRegex |
- Note
- has severe performance issues

fileDeleteByWildcard(
$wildcard
)
:
void| Name | Type | Description |
|---|---|---|
| $wildcard |
- Note
- has some severe performance issues

fileDeleteLocal(
$path
)
:
voidDeletes a file that has been fetched before.
| Name | Type | Description |
|---|---|---|
| $path |

fileExists(
$path
)
:
boolCheck if given file/dir exists.
| Name | Type | Description |
|---|---|---|
| $path |
| Type | Description |
|---|---|
| bool |

fileFetch(
string $filePath
)
:
string | falseFetches a file locally
| Name | Type | Description |
|---|---|---|
| $filePath | string |
| Type | Description |
|---|---|
| string | false | the file path, or false if fetching failed |

fileFetchContents(
$filePath
)
:
\contentsReturns file contents.
| Name | Type | Description |
|---|---|---|
| $filePath |
| Type | Description |
|---|---|
| \contents | string, or false in case of an error. |

fileLinkCopy(
$srcPath, $dstPath, $symLink
)
:
voidCreate symbolic or hard link to file.
| Name | Type | Description |
|---|---|---|
| $srcPath | ||
| $dstPath | ||
| $symLink |

fileStore(
string $filePath, string $scope
=
false, bool $delete
=
false, string $datatype
=
false
)
:
voidStores a file by path to the backend
| Name | Type | Description |
|---|---|---|
| $filePath | string | Path to the file being stored. |
| $scope | string | Means something like "file category". May be used to clean caches of a certain type. |
| $delete | bool | true if the file should be deleted after storing. |
| $datatype | string |

fileStoreContents(
string $filePath, string $contents, string $scope
=
false, string $datatype
=
false
)
:
voidStore file contents.
| Name | Type | Description |
|---|---|---|
| $filePath | string | Path to the file being stored. |
| $contents | string | Binary file content |
| $scope | string | "file category". May be used by cache management |
| $datatype | string | Datatype for the file. Also used to clean cache up |

getFileList(
array $scopes
=
false, boolean $excludeScopes
=
false
)
:
voidGet list of files stored in database.
Used in bin/php/clusterize.php.
| Name | Type | Description |
|---|---|---|
| $scopes | array | return only files that belong to any of these scopes |
| $excludeScopes | boolean | 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 |

isDBFileExpired(
int $expiry, int $curtime, int $ttl
)
:
boolCalculates if the DB file is expired or not.
| Name | Type | Description |
|---|---|---|
| $expiry | int | Time when file is to be expired, a value of -1 will disable this check. |
| $curtime | int | The current time to check against. |
| $ttl | int | Number of seconds the data can live, set to null to disable TTL. |
| Type | Description |
|---|---|
| bool |

isExpired(
int $expiry, int $curtime, int $ttl
)
:
boolCalculates if the current file data is expired or not.
| Name | Type | Description |
|---|---|---|
| $expiry | int | Time when file is to be expired, a value of -1 will disable this check. |
| $curtime | int | The current time to check against. |
| $ttl | int | Number of seconds the data can live, set to null to disable TTL. |
| Type | Description |
|---|---|
| bool |

isFileExpired(
string $fname, int $mtime, int $expiry, int $curtime, int $ttl
)
:
boolCalculates if the file data is expired or not.
| Name | Type | Description |
|---|---|---|
| $fname | string | Name of file, available for easy debugging. |
| $mtime | int | Modification time of file, can be set to false if file does not exist. |
| $expiry | int | Time when file is to be expired, a value of -1 will disable this check. |
| $curtime | int | The current time to check against. |
| $ttl | int | Number of seconds the data can live, set to null to disable TTL. |
| Type | Description |
|---|---|
| bool |

isLocalFileExpired(
int $expiry, int $curtime, int $ttl
)
:
boolCalculates if the local file is expired or not.
| Name | Type | Description |
|---|---|---|
| $expiry | int | Time when file is to be expired, a value of -1 will disable this check. |
| $curtime | int | The current time to check against. |
| $ttl | int | Number of seconds the data can live, set to null to disable TTL. |
| Type | Description |
|---|---|
| bool |

move(
string $dstPath
)
:
voidMove file.
| Name | Type | Description |
|---|---|---|
| $dstPath | string | Destination path |

passthrough(
)
:
voidOutputs file contents prepending them with appropriate HTTP headers.
- Deprecated
- This function should not be used since it cannot handle reading errors.

processCache(
$retrieveCallback, $generateCallback
=
null, $ttl
=
null, $expiry
=
null, $extraData
=
null
)
:
voidHandles 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 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
| Name | Type | Description |
|---|---|---|
| $retrieveCallback | ||
| $generateCallback | ||
| $ttl | ||
| $expiry | ||
| $extraData |
- See
- \$expiry
- See
- \$expiry
- Todo
- Reformat the doc so that it's readable

processFile(
$callback, $expiry
=
false, $extraData
=
null
)
:
voidProvides 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().
| Name | Type | Description |
|---|---|---|
| $callback | ||
| $expiry | ||
| $extraData |
- Note
- Unlike processCache() this returns null if the file cannot be accessed.
- See
- \self::processCache()

purge(
$printCallback
=
false, $microsleep
=
false, $max
=
false, $expiry
=
false
)
:
voidPurges local and remote file data for current file.
| Name | Type | Description |
|---|---|---|
| $printCallback | ||
| $microsleep | ||
| $max | ||
| $expiry |

requiresBinaryPurge(
)
:
boolThis method indicates if the cluster file handler requires binary files to be purged in order to be physically deleted
| Type | Description |
|---|---|
| bool |
- Deprecated
- Deprecated as of 4.5, use {@link eZClusterFileHandlerInterface::requiresPurge()} instead.
- Since
- 4.3

requiresClusterizing(
)
:
boolThis 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.
| Type | Description |
|---|---|
| bool |

requiresPurge(
)
:
boolThis method indicates if the cluster file handler requires binary files to be purged in order to be physically deleted
| Type | Description |
|---|---|
| bool |
- Since
- 4.5

startCacheGeneration(
)
:
boolStarts cache generation for the current file.
This is done by creating a file named by the original file name, prefixed with '.generating'.
| Type | Description |
|---|---|
| bool | false if the file is being generated, true if it is not |

storeContents(
string $contents, string $scope
=
false, string $datatype
=
false, bool $storeLocally
=
false
)
:
voidStore file contents using binary data
| Name | Type | Description |
|---|---|---|
| $contents | string | Binary file content |
| $scope | string | "file category". May be used by cache management |
| $datatype | string | Datatype for the file. Also used to clean cache up |
| $storeLocally | bool | If true the file will also be stored on the local file system. |