PHP Class Neos\Cache\Backend\SimpleFileBackend

Inheritance: extends AbstractBackend, implements Neos\Cache\Backend\PhpCapableBackendInterface, implements IterableBackendInterface
Show file Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Property Type Description
$baseDirectory string If not given this will be determined by the EnvironmentConfiguration
$cacheDirectory string Directory where the files are stored.
$cacheEntryFileExtension string A file extension to use for each cache entry.
$cacheEntryIdentifiers array
$cacheFilesIterator DirectoryIterator
$frozen boolean
$useIgBinary boolean Caching the result of extension_loaded() here is faster than calling extension_loaded() multiple times.

Public Methods

Method Description
__construct ( EnvironmentConfiguration $environmentConfiguration, array $options = [] )
collectGarbage ( ) : void Not necessary
current ( ) : mixed Returns the data of the current cache entry pointed to by the cache entry iterator.
flush ( ) : void Removes all cache entries of this cache.
get ( string $entryIdentifier ) : mixed Loads data from a cache file.
getBaseDirectory ( ) : string
getCacheDirectory ( ) : string Returns the directory where the cache files are stored
has ( string $entryIdentifier ) : boolean Checks if a cache entry with the specified identifier exists.
key ( ) : string Returns the identifier of the current cache entry pointed to by the cache entry iterator.
next ( ) : void Move forward to the next cache entry
remove ( string $entryIdentifier ) : boolean Removes all cache entries matching the specified identifier.
requireOnce ( string $entryIdentifier ) : mixed Loads PHP code from the cache and include_onces it right away.
rewind ( ) : void Rewinds the cache entry iterator to the first element
set ( string $entryIdentifier, string $data, array $tags = [], integer $lifetime = null ) : void Saves data in a cache file.
setBaseDirectory ( string $baseDirectory )
setCache ( Neos\Cache\Frontend\FrontendInterface $cache ) : void Sets a reference to the cache frontend which uses this backend and initializes the default cache directory.
setCacheDirectory ( string $cacheDirectory ) : void Sets the directory where the cache files are stored
valid ( ) : boolean Checks if the current position of the cache entry iterator is valid

Protected Methods

Method Description
configureCacheDirectory ( )
findCacheFilesByIdentifier ( string $entryIdentifier ) : mixed Tries to find the cache entry for the specified identifier.
isCacheFileExpired ( string $cacheEntryPathAndFilename ) : boolean Checks if the given cache entry files are still valid or if their lifetime has exceeded.
readCacheFile ( string $cacheEntryPathAndFilename, integer | null $offset = null, integer | null $maxlen = null ) : boolean | string Reads the cache data from the given cache file, using locking.
throwExceptionIfPathExceedsMaximumLength ( string $cacheEntryPathAndFilename ) : void
writeCacheFile ( string $cacheEntryPathAndFilename, string $data ) : boolean | integer Writes the cache data into the given cache file, using locking.

Method Details

__construct() public method

public __construct ( EnvironmentConfiguration $environmentConfiguration, array $options = [] )
$environmentConfiguration Neos\Cache\EnvironmentConfiguration
$options array

collectGarbage() public method

Not necessary
public collectGarbage ( ) : void
return void

configureCacheDirectory() protected method

protected configureCacheDirectory ( )

current() public method

Returns the data of the current cache entry pointed to by the cache entry iterator.
public current ( ) : mixed
return mixed

findCacheFilesByIdentifier() protected method

Tries to find the cache entry for the specified identifier.
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

flush() public method

Removes all cache entries of this cache.
public flush ( ) : 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

getBaseDirectory() public method

public getBaseDirectory ( ) : string
return string

getCacheDirectory() public method

Returns the directory where the cache files are stored
public getCacheDirectory ( ) : string
return string Full path of the cache directory

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

isCacheFileExpired() protected method

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

key() public method

Returns the identifier of the current cache entry pointed to by the cache entry iterator.
public key ( ) : string
return string

next() public method

Move forward to the next cache entry
public next ( ) : void
return void

readCacheFile() protected method

Reads the cache data from the given cache file, using locking.
protected readCacheFile ( string $cacheEntryPathAndFilename, integer | null $offset = null, integer | null $maxlen = null ) : boolean | string
$cacheEntryPathAndFilename string
$offset integer | null
$maxlen integer | null
return boolean | string The contents of the cache file or FALSE on error

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

rewind() public method

Rewinds the cache entry iterator to the first element
public rewind ( ) : void
return void

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 Ignored in this type of cache backend
$lifetime integer Ignored in this type of cache backend
return void

setBaseDirectory() public method

public setBaseDirectory ( string $baseDirectory )
$baseDirectory string

setCache() public method

Sets a reference to the cache frontend which uses this backend and initializes the default cache directory.
public setCache ( Neos\Cache\Frontend\FrontendInterface $cache ) : void
$cache Neos\Cache\Frontend\FrontendInterface The cache frontend
return void

setCacheDirectory() public method

Sets the directory where the cache files are stored
public setCacheDirectory ( string $cacheDirectory ) : void
$cacheDirectory string Full path of the cache directory
return void

throwExceptionIfPathExceedsMaximumLength() protected method

protected throwExceptionIfPathExceedsMaximumLength ( string $cacheEntryPathAndFilename ) : void
$cacheEntryPathAndFilename string
return void

valid() public method

Checks if the current position of the cache entry iterator is valid
public valid ( ) : boolean
return boolean TRUE if the current position is valid, otherwise FALSE

writeCacheFile() protected method

Writes the cache data into the given cache file, using locking.
protected writeCacheFile ( string $cacheEntryPathAndFilename, string $data ) : boolean | integer
$cacheEntryPathAndFilename string
$data string
return boolean | integer Return value of file_put_contents

Property Details

$baseDirectory protected property

If not given this will be determined by the EnvironmentConfiguration
protected string $baseDirectory
return string

$cacheDirectory protected property

Directory where the files are stored.
protected string $cacheDirectory
return string

$cacheEntryFileExtension protected property

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

$cacheEntryIdentifiers protected property

protected array $cacheEntryIdentifiers
return array

$cacheFilesIterator protected property

protected DirectoryIterator $cacheFilesIterator
return DirectoryIterator

$frozen protected property

protected bool $frozen
return boolean

$useIgBinary protected property

Caching the result of extension_loaded() here is faster than calling extension_loaded() multiple times.
protected bool $useIgBinary
return boolean