ApcuBackend
class ApcuBackend extends AbstractBackend implements TaggableBackendInterface, IterableBackendInterface, PhpCapableBackendInterface (View source)
A caching backend which stores cache entries by using APCu.
This backend uses the following types of keys:
- entry_xxx the actual cache entry with the data to be stored
- tag_xxx xxx is tag name, value is array of associated identifiers identifier. This is "forward" tag index. It is mainly used for obtaining content by tag (get identifier by tag -> get content by identifier)
- ident_xxx xxx is identifier, value is array of associated tags. This is "reverse" tag index. It provides quick access for all tags associated with this identifier and used when removing the identifier
- tagIndex Value is a List of all tags (array)
Each key is prepended with a prefix. By default prefix consists from two parts separated by underscore character and ends in yet another underscore character:
- "Flow"
- MD5 of path to Flow and the current context (Production, Development, ...)
This prefix makes sure that keys from the different installations do not conflict.
Traits
Constants
DATETIME_EXPIRYTIME_UNLIMITED |
|
UNLIMITED_LIFETIME |
|
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 data from other data possible stored in the APCu |
|
protected int | $defaultLifetime | Default lifetime of a cache entry in seconds |
from AbstractBackend |
protected EnvironmentConfiguration | $environmentConfiguration | from AbstractBackend | |
protected array | $_requiredEntryIdentifiers | from RequireOnceFromValueTrait | |
protected APCUIterator|null | $cacheEntriesIterator |
Methods
Constructs this backend
No description
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.
Loads PHP code from the cache and require_onces it right away.
Saves data in the cache.
Loads data from the cache.
Checks if a cache entry with the specified identifier exists.
Removes all cache entries matching the specified identifier.
Finds and returns all cache entry identifiers which are tagged by the specified tag.
Finds all tags for the given identifier. This function uses reverse tag index to search for tags.
Removes all cache entries of this cache.
Removes all cache entries of this cache which are tagged by the specified tag.
Associates the identifier with the given tags
Removes association of the identifier with the given tags
Does nothing, as APCu does GC itself
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
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)
Initializes the identifier prefix when setting the cache.
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.
mixed
requireOnce(string $entryIdentifier)
Loads PHP code from the cache and require_onces it right away.
void
set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null)
Saves data in the cache.
mixed
get(string $entryIdentifier)
Loads data from the cache.
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 but if - for what reason ever - old entries for the identifier still exist, they are removed as well.
array
findIdentifiersByTag(string $tag)
Finds and returns all cache entry identifiers which are tagged by the specified tag.
protected array
findTagsByIdentifier(string $identifier)
Finds all tags for the given identifier. This function uses reverse tag index to search for tags.
void
flush()
Removes all cache entries of this cache.
int
flushByTag(string $tag)
Removes all cache entries of this cache which are tagged by the specified tag.
protected void
addIdentifierToTags(string $entryIdentifier, array $tags)
Associates the identifier with the given tags
protected void
removeIdentifierFromAllTags(string $entryIdentifier)
Removes association of the identifier with the given tags
void
collectGarbage()
Does nothing, as APCu does GC itself
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