PHP Class Neos\Cache\Backend\FileBackend

Inheritance: extends SimpleFileBackend, implements Neos\Cache\Backend\PhpCapableBackendInterface, implements Neos\Cache\Backend\FreezableBackendInterface, implements Neos\Cache\Backend\TaggableBackendInterface
ファイルを表示 Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Property Type Description
$cacheEntryFileExtension string A file extension to use for each cache entry.
$cacheEntryIdentifiers array
$frozen boolean

Public Methods

Method Description
collectGarbage ( ) : void Does garbage collection
findIdentifiersByTag ( string $searchedTag ) : array Finds and returns all cache entry identifiers which are tagged by the specified tag.
flush ( ) : void Removes all cache entries of this cache and sets the frozen flag to FALSE.
flushByTag ( string $tag ) : integer Removes all cache entries of this cache which are tagged by the specified tag.
freeze ( ) : void Freezes this cache backend.
get ( string $entryIdentifier ) : mixed Loads data from a cache file.
has ( string $entryIdentifier ) : boolean Checks if a cache entry with the specified identifier exists.
isFrozen ( ) : boolean Tells if this backend is frozen.
remove ( string $entryIdentifier ) : boolean Removes all cache entries matching the specified identifier.
requireOnce ( string $entryIdentifier ) : mixed Loads PHP code from the cache and require_onces it right away.
set ( string $entryIdentifier, string $data, array $tags = [], integer $lifetime = null ) : void Saves data in a cache file.
setCache ( Neos\Cache\Frontend\FrontendInterface $cache ) : void Sets a reference to the cache frontend which uses this backend and initializes the default cache directory.

Protected Methods

Method Description
findCacheFilesByIdentifier ( string $entryIdentifier ) : mixed Tries to find the cache entry for the specified identifier.
internalGet ( string $entryIdentifier, boolean $acquireLock = true ) : boolean | string Internal get method, allows to nest locks by using the $acquireLock flag
isCacheFileExpired ( string $cacheEntryPathAndFilename, boolean $acquireLock = true ) : boolean Checks if the given cache entry files are still valid or if their lifetime has exceeded.

Method Details

collectGarbage() public method

Does garbage collection
public collectGarbage ( ) : void
return void

findCacheFilesByIdentifier() protected method

Usually only one cache entry should be found - if more than one exist, this is due to some error or crash.
protected findCacheFilesByIdentifier ( string $entryIdentifier ) : mixed
$entryIdentifier string The cache entry identifier
return mixed The filenames (including path) as an array if one or more entries could be found, otherwise FALSE

findIdentifiersByTag() public method

Finds and returns all cache entry identifiers which are tagged by the specified tag.
public findIdentifiersByTag ( string $searchedTag ) : array
$searchedTag string The tag to search for
return array An array with identifiers of all matching entries. An empty array if no entries matched

flush() public method

Removes all cache entries of this cache and sets the frozen flag to FALSE.
public flush ( ) : void
return void

flushByTag() public method

Removes all cache entries of this cache which are tagged by the specified tag.
public flushByTag ( string $tag ) : integer
$tag string The tag the entries must have
return integer The number of entries which have been affected by this flush

freeze() public method

All data in a frozen backend remains unchanged and methods which try to add or modify data result in an exception thrown. Possible expiry times of individual cache entries are ignored. On the positive side, a frozen cache backend is much faster on read access. A frozen backend can only be thawed by calling the flush() method.
public freeze ( ) : void
return void

get() public method

Loads data from a cache file.
public get ( string $entryIdentifier ) : mixed
$entryIdentifier string An identifier which describes the cache entry to load
return mixed The cache entry's content as a string or FALSE if the cache entry could not be loaded

has() public method

Checks if a cache entry with the specified identifier exists.
public has ( string $entryIdentifier ) : boolean
$entryIdentifier string
return boolean TRUE if such an entry exists, FALSE if not

internalGet() protected method

Internal get method, allows to nest locks by using the $acquireLock flag
protected internalGet ( string $entryIdentifier, boolean $acquireLock = true ) : boolean | string
$entryIdentifier string
$acquireLock boolean
return boolean | string

isCacheFileExpired() protected method

Checks if the given cache entry files are still valid or if their lifetime has exceeded.
protected isCacheFileExpired ( string $cacheEntryPathAndFilename, boolean $acquireLock = true ) : boolean
$cacheEntryPathAndFilename string
$acquireLock boolean
return boolean

isFrozen() public method

Tells if this backend is frozen.
public isFrozen ( ) : boolean
return boolean

remove() public method

Usually this only affects one entry.
public remove ( string $entryIdentifier ) : boolean
$entryIdentifier string Specifies the cache entry to remove
return boolean TRUE if (at least) an entry could be removed or FALSE if no entry was found

requireOnce() public method

Loads PHP code from the cache and require_onces it right away.
public requireOnce ( string $entryIdentifier ) : mixed
$entryIdentifier string An identifier which describes the cache entry to load
return mixed Potential return value from the include operation

set() public method

Saves data in a cache file.
public set ( string $entryIdentifier, string $data, array $tags = [], integer $lifetime = null ) : void
$entryIdentifier string An identifier for this specific cache entry
$data string The data to be stored
$tags array Tags to associate with this cache entry
$lifetime integer Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
return void

setCache() public method

This method also detects if this backend is frozen and sets the internal flag accordingly.
public setCache ( Neos\Cache\Frontend\FrontendInterface $cache ) : void
$cache Neos\Cache\Frontend\FrontendInterface The cache frontend
return void

Property Details

$cacheEntryFileExtension protected_oe property

A file extension to use for each cache entry.
protected string $cacheEntryFileExtension
return string

$cacheEntryIdentifiers protected_oe property

protected array $cacheEntryIdentifiers
return array

$frozen protected_oe property

protected bool $frozen
return boolean