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.
Constants
- DATASIZE_DIGITS = 10
- DATETIME_EXPIRYTIME_UNLIMITED = '9999-12-31T23:59:59+0000'
- EXPIRYTIME_FORMAT = 'YmdHis'
- EXPIRYTIME_LENGTH = 14
- SEPARATOR = '^'
- UNLIMITED_LIFETIME = 0
Properties
- $cache : FrontendInterface
- Reference to the cache which uses this backend
- $cacheDirectory : string
- Directory where the files are stored
- $cacheEntryFileExtension : string
- A file extension to use for each cache entry.
- $cacheEntryIdentifiers : array<string|int, mixed>
- $cacheIdentifier : string
- $context : string
- The current application context
- $defaultLifetime : int
- Default lifetime of a cache entry in seconds
- $frozen : bool
- $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
- Constructs this backend
- collectGarbage() : mixed
- Not necessary
- flush() : mixed
- Removes all cache entries of this cache.
- flushByTags() : mixed
- Backwards compatibility safeguard since re-introducing flushByTags as API.
- get() : mixed
- Loads data from a cache file.
- 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_onces it right away.
- set() : mixed
- Saves data in a cache file.
- setCache() : mixed
- Sets a reference to the cache frontend which uses this backend and initializes the default cache directory.
- setCacheDirectory() : mixed
- 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() : mixed
- Sets the default lifetime for this cache backend
- calculateExpiryTime() : DateTime
- Calculates the expiry time by the given lifetime. If no lifetime is specified, the default lifetime is used.
- createFinalCacheDirectory() : mixed
- Create the final cache directory if it does not exist.
- findCacheFilesByIdentifier() : mixed
- Tries to find the cache entry for the specified identifier.
- isCacheFileExpired() : bool
- Checks if the given cache entry files are still valid or if their lifetime has exceeded.
Constants
DATASIZE_DIGITS
    public
        mixed
    DATASIZE_DIGITS
    = 10
    
    
    
    
DATETIME_EXPIRYTIME_UNLIMITED
    public
        mixed
    DATETIME_EXPIRYTIME_UNLIMITED
    = '9999-12-31T23:59:59+0000'
    
    
    
    
EXPIRYTIME_FORMAT
    public
        mixed
    EXPIRYTIME_FORMAT
    = 'YmdHis'
    
    
    
    
EXPIRYTIME_LENGTH
    public
        mixed
    EXPIRYTIME_LENGTH
    = 14
    
    
    
    
SEPARATOR
    public
        mixed
    SEPARATOR
    = '^'
    
    
    
    
UNLIMITED_LIFETIME
    public
        mixed
    UNLIMITED_LIFETIME
    = 0
    
    
    
    
Properties
$cache
Reference to the cache which uses this backend
        protected
            FrontendInterface
    $cache
    
    
    
    
    
    
$cacheDirectory
Directory where the files are stored
        protected
            string
    $cacheDirectory
     = ''
    
    
    
    
    
$cacheEntryFileExtension
A file extension to use for each cache entry.
        protected
            string
    $cacheEntryFileExtension
     = ''
    
    
    
    
    
$cacheEntryIdentifiers
        protected
            array<string|int, mixed>
    $cacheEntryIdentifiers
     = []
    
    
    
    
    
$cacheIdentifier
        protected
            string
    $cacheIdentifier
    
    
    
    
    
    
$context
The current application context
        protected
            string
    $context
    
        This variable is currently unused and set to "production" always. It is only kept to keep backwards compatibility.
$defaultLifetime
Default lifetime of a cache entry in seconds
        protected
            int
    $defaultLifetime
     = 3600
    
    
    
    
    
$frozen
        protected
            bool
    $frozen
     = false
    
    
    
    
    
$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
     = ''
    
        Temporary path to cache directory
Methods
__construct()
Constructs this backend
    public
                    __construct(string $context[, array<string|int, mixed> $options = [] ]) : mixed
    Parameters
- $context : string
- 
                    Unused, for backward compatibility only 
- $options : array<string|int, mixed> = []
- 
                    Configuration options - depends on the actual backend 
Tags
collectGarbage()
Not necessary
    public
                    collectGarbage() : mixed
    flush()
Removes all cache entries of this cache.
    public
                    flush() : mixed
    flushByTags()
Backwards compatibility safeguard since re-introducing flushByTags as API.
    public
                    flushByTags(array<string|int, string> $tags) : mixed
    See https://review.typo3.org/#/c/50537/ comments for patch set 14.
The method is here even though it is only required for TaggableBackendInterface. We add it here to ensure third party cache backends do not fail but instead delegate to a less efficient linear flushing behavior.
Parameters
- $tags : array<string|int, string>
get()
Loads data from a cache file.
    public
                    get(string $entryIdentifier) : mixed
    Parameters
- $entryIdentifier : string
- 
                    An identifier which describes the cache entry to load 
Tags
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
    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
Tags
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.
Parameters
- $entryIdentifier : string
- 
                    Specifies the cache entry to remove 
Tags
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 
Tags
Return values
mixed —Potential return value from the include operation
requireOnce()
Loads PHP code from the cache and require_onces it right away.
    public
                    requireOnce(string $entryIdentifier) : mixed
    Parameters
- $entryIdentifier : string
- 
                    An identifier which describes the cache entry to load 
Tags
Return values
mixed —Potential return value from the include operation
set()
Saves data in a cache file.
    public
                    set(string $entryIdentifier, string $data[, array<string|int, mixed> $tags = [] ][, int $lifetime = null ]) : mixed
    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 
- $lifetime : int = null
- 
                    This cache backend does not support life times 
Tags
setCache()
Sets a reference to the cache frontend which uses this backend and initializes the default cache directory.
    public
                    setCache(FrontendInterface $cache) : mixed
    Parameters
- $cache : FrontendInterface
- 
                    The cache frontend 
Tags
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) : mixed
    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
- 
                    The cache base directory. If a relative path 
Tags
setDefaultLifetime()
Sets the default lifetime for this cache backend
    public
                    setDefaultLifetime(int $defaultLifetime) : mixed
    Parameters
- $defaultLifetime : int
- 
                    Default lifetime of this cache backend in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime. 
Tags
calculateExpiryTime()
Calculates the expiry time by the given lifetime. If no lifetime is specified, the default lifetime is used.
    protected
                    calculateExpiryTime([int $lifetime = null ]) : DateTime
    Parameters
- $lifetime : int = null
- 
                    The lifetime in seconds 
Return values
DateTime —The expiry time
createFinalCacheDirectory()
Create the final cache directory if it does not exist.
    protected
                    createFinalCacheDirectory(string $finalCacheDirectory) : mixed
    Parameters
- $finalCacheDirectory : string
- 
                    Absolute path to final cache directory 
Tags
findCacheFilesByIdentifier()
Tries to find the cache entry for the specified identifier.
    protected
                    findCacheFilesByIdentifier(string $entryIdentifier) : mixed
    Parameters
- $entryIdentifier : string
- 
                    The cache entry identifier 
Return values
mixed —The file names (including path) as an array if one or more entries could be found, otherwise FALSE
isCacheFileExpired()
Checks if the given cache entry files are still valid or if their lifetime has exceeded.
    protected
                    isCacheFileExpired(string $cacheEntryPathAndFilename) : bool
    Parameters
- $cacheEntryPathAndFilename : string