SimpleFileBackend extends AbstractBackend implements PhpCapableBackendInterface

A caching backend which stores cache entries in files, but does not support or care about expiry times and tags.

Table of Contents

Interfaces

PhpCapableBackendInterface
A contract for a cache backend which is capable of storing, retrieving and including PHP source code.

Properties

$cacheDirectory  : string
Directory where the files are stored
$cacheEntryFileExtension  : string
A file extension to use for each cache entry.
$cacheIdentifier  : string
$defaultLifetime  : int
Default lifetime of a cache entry in seconds
$temporaryCacheDirectory  : string
Temporary path to cache directory before setCache() was called. It is set by setCacheDirectory() and used in setCache() method which calls the directory creation if needed. The variable is not used afterwards, the final cache directory path is stored in $this->cacheDirectory then.

Methods

__construct()  : mixed
collectGarbage()  : void
No-op
flush()  : void
Removes all cache entries of this cache.
get()  : mixed
Loads data from the cache.
getCacheDirectory()  : string
Returns the directory where the cache files are stored
has()  : bool
Checks if a cache entry with the specified identifier exists.
remove()  : bool
Removes all cache entries matching the specified identifier.
require()  : mixed
Loads PHP code from the cache and require() it right away.
requireOnce()  : mixed
Loads PHP code from the cache and require_once() it right away.
set()  : void
Saves data in the cache.
setCache()  : void
Sets a reference to the cache frontend which uses this backend
setCacheDirectory()  : void
Sets the directory where the cache files are stored. By default it is assumed that the directory is below TYPO3's Project Path. However, an absolute path can be selected, too.
setDefaultLifetime()  : void
Sets the default lifetime for this cache backend
createFinalCacheDirectory()  : void
Create the final cache directory if it does not exist.
isCacheFileExpired()  : bool

Properties

$cacheDirectory

Directory where the files are stored

protected string $cacheDirectory = ''

$cacheEntryFileExtension

A file extension to use for each cache entry.

protected string $cacheEntryFileExtension = ''

$cacheIdentifier

protected string $cacheIdentifier

$defaultLifetime

Default lifetime of a cache entry in seconds

protected int $defaultLifetime = 3600

$temporaryCacheDirectory

Temporary path to cache directory before setCache() was called. It is set by setCacheDirectory() and used in setCache() method which calls the directory creation if needed. The variable is not used afterwards, the final cache directory path is stored in $this->cacheDirectory then.

protected string $temporaryCacheDirectory = ''

Methods

__construct()

public __construct([array<string|int, mixed> $options = [] ]) : mixed
Parameters
$options : array<string|int, mixed> = []

Configuration options - depends on the actual backend

collectGarbage()

No-op

public collectGarbage() : void

flush()

Removes all cache entries of this cache.

public flush() : void

get()

Loads data from the cache.

public get(string $entryIdentifier) : mixed
Parameters
$entryIdentifier : string

An identifier which describes the cache entry to load

Return values
mixed

The cache entry's content as a string or FALSE if the cache entry could not be loaded

getCacheDirectory()

Returns the directory where the cache files are stored

public getCacheDirectory() : string
Internal

Misused in tests

Tags
todo:

Fix tests and protect

Return values
string

Full path of the cache directory

has()

Checks if a cache entry with the specified identifier exists.

public has(string $entryIdentifier) : bool
Parameters
$entryIdentifier : string

An identifier specifying the cache entry

Return values
bool

TRUE if such an entry exists, FALSE if not

remove()

Removes all cache entries matching the specified identifier.

public remove(string $entryIdentifier) : bool

Usually this only affects one entry but if - for what reason ever - old entries for the identifier still exist, they are removed as well.

Parameters
$entryIdentifier : string

Specifies the cache entry to remove

Return values
bool

TRUE if (at least) an entry could be removed or FALSE if no entry was found

require()

Loads PHP code from the cache and require() it right away.

public require(string $entryIdentifier) : mixed
Parameters
$entryIdentifier : string

An identifier which describes the cache entry to load

Return values
mixed

Potential return value from the include operation

requireOnce()

Loads PHP code from the cache and require_once() it right away.

public requireOnce(string $entryIdentifier) : mixed
Parameters
$entryIdentifier : string

An identifier which describes the cache entry to load

Return values
mixed

Potential return value from the include operation

set()

Saves data in the cache.

public set(string $entryIdentifier, string $data[, array<string|int, mixed> $tags = [] ][, int|null $lifetime = null ]) : void
Parameters
$entryIdentifier : string

An identifier for this specific cache entry

$data : string

The data to be stored

$tags : array<string|int, mixed> = []

Tags to associate with this cache entry. If the backend does not support tags, this option can be ignored.

$lifetime : int|null = null

Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.

setCacheDirectory()

Sets the directory where the cache files are stored. By default it is assumed that the directory is below TYPO3's Project Path. However, an absolute path can be selected, too.

public setCacheDirectory(string $cacheDirectory) : void

This method enables to use a cache path outside of TYPO3's Project Path. The final cache path is checked and created in createFinalCacheDirectory(), called by setCache() method, which is done after the cacheDirectory option was handled.

Parameters
$cacheDirectory : string
Internal

Misused in tests

Tags
todo:

Fix tests and protect

setDefaultLifetime()

Sets the default lifetime for this cache backend

public setDefaultLifetime(int $defaultLifetime) : void
Parameters
$defaultLifetime : int

Default lifetime of this cache backend in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.

Internal

Misused for testing purposes.

Tags
todo:

Fix tests and protect or remove

createFinalCacheDirectory()

Create the final cache directory if it does not exist.

protected createFinalCacheDirectory(string $finalCacheDirectory) : void
Parameters
$finalCacheDirectory : string

isCacheFileExpired()

protected isCacheFileExpired(string $cacheEntryPathAndFilename) : bool
Parameters
$cacheEntryPathAndFilename : string
Return values
bool

        
On this page

Search results