kernel/private/interfaces/ezclusterfilehandlerinterface.php

Show: inherited
    Table of Contents

    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

    Package: Default

    Cluster file handlers interface

    Children
    \eZDFSFileHandler

    Methods

    methodpublicabortCacheGeneration( ) : void

    Aborts the current cache generation process.

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

    methodpubliccheckCacheGenerationTimeout( ) : void

    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

    methodpublicdelete( ) : void

    Deletes specified file/directory.

    If a directory specified it is deleted recursively.

    methodpublicdeleteLocal( ) : void

    Deletes a file that has been fetched before.

    methodpublicendCacheGeneration(  $rename = true ) : void

    Ends the cache generation started by startCacheGeneration().

    Parameters
    Name Type Description
    $rename
    methodpublicexists( ) : bool

    Check if given file/dir exists.

    Returns
    Type Description
    bool
    Details
    Note
    This function does not interact with database. Instead, it just returns existance status determined in the constructor.  
    methodpublicfetch( bool $noLocalCache = false ) : void

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

    Parameters
    Name Type Description
    $noLocalCache bool
    methodpublicfetchContents( ) : string | bool

    Returns file contents.

    Returns
    Type Description
    string | bool contents string, or false in case of an error.
    methodpublicfetchUnique( ) : string

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

    Returns
    Type Description
    string path to the saved file
    methodpublicfileCopy(  $srcPath,  $dstPath ) : void

    Copy file.

    Parameters
    Name Type Description
    $srcPath
    $dstPath
    methodpublicfileDelete(  $path,  $fnamePart = false ) : void

    Deletes specified file/directory.

    If a directory specified it is deleted recursively.

    Parameters
    Name Type Description
    $path
    $fnamePart
    methodpublicfileDeleteByDirList(  $dirList,  $commonPath,  $commonSuffix ) : void

    Parameters
    Name Type Description
    $dirList
    $commonPath
    $commonSuffix
    methodpublicfileDeleteByRegex(  $dir,  $fileRegex ) : void

    Parameters
    Name Type Description
    $dir
    $fileRegex
    Details
    Note
    has severe performance issues  
    methodpublicfileDeleteByWildcard(  $wildcard ) : void

    Parameters
    Name Type Description
    $wildcard
    Details
    Note
    has some severe performance issues  
    methodpublicfileDeleteLocal(  $path ) : void

    Deletes a file that has been fetched before.

    Parameters
    Name Type Description
    $path
    methodpublicfileExists(  $path ) : bool

    Check if given file/dir exists.

    Parameters
    Name Type Description
    $path
    Returns
    Type Description
    bool
    methodpublicfileFetch( string $filePath ) : string | false

    Fetches a file locally

    Parameters
    Name Type Description
    $filePath string
    Returns
    Type Description
    string | false the file path, or false if fetching failed
    methodpublicfileFetchContents(  $filePath ) : \contents

    Returns file contents.

    Parameters
    Name Type Description
    $filePath
    Returns
    Type Description
    \contents string, or false in case of an error.
    methodpublicfileLinkCopy(  $srcPath,  $dstPath,  $symLink ) : void

    Create symbolic or hard link to file.

    Parameters
    Name Type Description
    $srcPath
    $dstPath
    $symLink
    methodpublicfileMove(  $srcPath,  $dstPath ) : void

    Move file.

    Parameters
    Name Type Description
    $srcPath
    $dstPath
    methodpublicfileStore( string $filePath, string $scope = false, bool $delete = false, string $datatype = false ) : void

    Stores a file by path to the backend

    Parameters
    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
    methodpublicfileStoreContents( string $filePath, string $contents, string $scope = false, string $datatype = false ) : void

    Store file contents.

    Parameters
    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

    methodpublicgetFileList( array $scopes = false, boolean $excludeScopes = false ) : void

    Get list of files stored in database.

    Used in bin/php/clusterize.php.

    Parameters
    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

    methodpublicisDBFileExpired( int $expiry, int $curtime, int $ttl ) : bool

    Calculates if the DB file is expired or not.

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

    Returns
    Type Description
    bool
    methodpublicisExpired( int $expiry, int $curtime, int $ttl ) : bool

    Calculates if the current file data is expired or not.

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

    Returns
    Type Description
    bool
    methodpublicisFileExpired( string $fname, int $mtime, int $expiry, int $curtime, int $ttl ) : bool

    Calculates if the file data is expired or not.

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

    Returns
    Type Description
    bool
    methodpublicisLocalFileExpired( int $expiry, int $curtime, int $ttl ) : bool

    Calculates if the local file is expired or not.

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

    Returns
    Type Description
    bool
    methodpublicmove( string $dstPath ) : void

    Move file.

    Parameters
    Name Type Description
    $dstPath string

    Destination path

    methodpublicmtime( ) : int | null

    Returns file modification time.

    Returns
    Type Description
    int | null
    methodpublicname( ) : string

    Returns file name.

    Returns
    Type Description
    string
    methodpublicpassthrough( ) : void

    Outputs file contents prepending them with appropriate HTTP headers.

    Details
    Deprecated
    This function should not be used since it cannot handle reading errors.  
    methodpublicprocessCache(  $retrieveCallback,  $generateCallback = null,  $ttl = null,  $expiry = null,  $extraData = null ) : void

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

    Parameters
    Name Type Description
    $retrieveCallback
    $generateCallback
    $ttl
    $expiry
    $extraData
    Details
    See
    \$expiry  
    See
    \$expiry  
    Todo
    Reformat the doc so that it's readable  
    methodpublicprocessFile(  $callback,  $expiry = false,  $extraData = null ) : void

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

    Parameters
    Name Type Description
    $callback
    $expiry
    $extraData
    Details
    Note
    Unlike processCache() this returns null if the file cannot be accessed.  
    See
    \self::processCache()  
    methodpublicpurge(  $printCallback = false,  $microsleep = false,  $max = false,  $expiry = false ) : void

    Purges local and remote file data for current file.

    Parameters
    Name Type Description
    $printCallback
    $microsleep
    $max
    $expiry
    methodpublicrequiresBinaryPurge( ) : bool

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

    Returns
    Type Description
    bool
    Details
    Deprecated
    Deprecated as of 4.5, use {@link eZClusterFileHandlerInterface::requiresPurge()} instead.  
    Since
    4.3  
    methodpublicrequiresClusterizing( ) : bool

    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
    Type Description
    bool
    methodpublicrequiresPurge( ) : bool

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

    Returns
    Type Description
    bool
    Details
    Since
    4.5  
    methodpublicsize( ) : int | null

    Returns file size.

    Returns
    Type Description
    int | null
    methodpublicstartCacheGeneration( ) : bool

    Starts cache generation for the current file.

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

    Returns
    Type Description
    bool false if the file is being generated, true if it is not
    methodpublicstat( ) : void

    Returns file metadata.

    methodpublicstoreContents( string $contents, string $scope = false, string $datatype = false, bool $storeLocally = false ) : void

    Store file contents using binary data

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

    Documentation was generated by DocBlox 0.18.1.