SimpleFileBackend
class SimpleFileBackend extends AbstractBackend implements PhpCapableBackendInterface, IterableBackendInterface, WithSetupInterface, WithStatusInterface (View source)
A caching backend which stores cache entries in files, but does not support or care about expiry times and tags.
Constants
DATETIME_EXPIRYTIME_UNLIMITED |
|
UNLIMITED_LIFETIME |
|
SEPARATOR |
|
EXPIRYTIME_FORMAT |
|
EXPIRYTIME_LENGTH |
|
DATASIZE_DIGITS |
|
Properties
protected FrontendInterface | $cache | Reference to the cache frontend which uses this backend |
from AbstractBackend |
protected string | $cacheIdentifier | from AbstractBackend | |
protected string | $identifierPrefix | A prefix to seperate stored by appliaction context and cache |
from AbstractBackend |
protected int | $defaultLifetime | Default lifetime of a cache entry in seconds |
from AbstractBackend |
protected EnvironmentConfiguration | $environmentConfiguration | from AbstractBackend | |
protected string | $cacheDirectory | Directory where the files are stored. |
|
protected string | $cacheEntryFileExtension | A file extension to use for each cache entry. |
|
protected string[] | $cacheEntryIdentifiers | ||
protected bool | $frozen | ||
protected bool | $useIgBinary | If the extension "igbinary" is installed, use it for increased performance. |
|
protected DirectoryIterator | $cacheFilesIterator | ||
protected string | $baseDirectory | Overrides the base directory for this cache, the effective directory will be a subdirectory of this. |
Methods
Constructs this backend
No description
Sets a reference to the cache frontend which uses this backend and initializes the default cache directory.
Sets the default lifetime for this cache backend
Calculates the expiry time by the given lifetime. If no lifetime is specified, the default lifetime is used.
Returns the internally used, prefixed entry identifier for the given public entry identifier.
Sets the directory where the cache files are stored
Returns the directory where the cache files are stored
Saves data in a cache file.
Loads data from a cache file.
Checks if a cache entry with the specified identifier exists.
Removes all cache entries matching the specified identifier.
Removes all cache entries of this cache.
Checks if the given cache entry files are still valid or if their lifetime has exceeded.
Not necessary
Tries to find the cache entry for the specified identifier.
Loads PHP code from the cache and include_onces it right away.
Returns the data of the current cache entry pointed to by the cache entry iterator.
Move forward to the next cache entry
Returns the identifier of the current cache entry pointed to by the cache entry iterator.
Checks if the current position of the cache entry iterator is valid
Rewinds the cache entry iterator to the first element
No description
No description
No description
No description
No description
Reads the cache data from the given cache file, using locking.
Writes the cache data into the given cache file, using locking.
Sets up this backend by creating the required cache directory if it doesn't exist yet
Details
__construct(EnvironmentConfiguration $environmentConfiguration, array $options = [])
Constructs this backend
protected void
setProperties(array $properties, bool $throwExceptionIfPropertyNotSettable = true)
No description
protected bool
setProperty(string $propertyName, mixed $propertyValue)
No description
void
setCache(FrontendInterface $cache)
Sets a reference to the cache frontend which uses this backend and initializes the default cache directory.
void
setDefaultLifetime(int|string $defaultLifetime)
Sets the default lifetime for this cache backend
protected DateTime
calculateExpiryTime(int $lifetime = null)
Calculates the expiry time by the given lifetime. If no lifetime is specified, the default lifetime is used.
string
getPrefixedIdentifier(string $entryIdentifier)
Returns the internally used, prefixed entry identifier for the given public entry identifier.
While Flow applications will mostly refer to the simple entry identifier, it may be necessary to know the actual identifier used by the cache backend in order to share cache entries with other applications. This method allows for retrieving it.
Note that, in case of the AbstractBackend, this method is returns just the given entry identifier.
void
setCacheDirectory(string $cacheDirectory)
Sets the directory where the cache files are stored
string
getCacheDirectory()
Returns the directory where the cache files are stored
void
set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null)
Saves data in a cache file.
mixed
get(string $entryIdentifier)
Loads data from a cache file.
bool
has(string $entryIdentifier)
Checks if a cache entry with the specified identifier exists.
bool
remove(string $entryIdentifier)
Removes all cache entries matching the specified identifier.
Usually this only affects one entry.
void
flush()
Removes all cache entries of this cache.
protected bool
isCacheFileExpired(string $cacheEntryPathAndFilename)
Checks if the given cache entry files are still valid or if their lifetime has exceeded.
void
collectGarbage()
Not necessary
protected mixed
findCacheFilesByIdentifier(string $entryIdentifier)
Tries to find the cache entry for the specified identifier.
mixed
requireOnce(string $entryIdentifier)
Loads PHP code from the cache and include_onces it right away.
mixed
current()
Returns the data of the current cache entry pointed to by the cache entry iterator.
void
next()
Move forward to the next cache entry
string
key()
Returns the identifier of the current cache entry pointed to by the cache entry iterator.
bool
valid()
Checks if the current position of the cache entry iterator is valid
void
rewind()
Rewinds the cache entry iterator to the first element
protected void
throwExceptionIfPathExceedsMaximumLength(string $cacheEntryPathAndFilename)
No description
string
getBaseDirectory()
No description
void
setBaseDirectory(string $baseDirectory)
No description
protected void
configureCacheDirectory()
No description
protected void
verifyCacheDirectory()
No description
protected bool|string
readCacheFile(string $cacheEntryPathAndFilename, int $offset = null, int $maxlen = null)
Reads the cache data from the given cache file, using locking.
protected bool
writeCacheFile(string $cacheEntryPathAndFilename, string $data)
Writes the cache data into the given cache file, using locking.
Result
setup()
Sets up this backend by creating the required cache directory if it doesn't exist yet
Result
getStatus()
Validates that the configured cache directory exists and is writeable and returns some details about its configuration if that's the case