FreezableBackendInterface extends BackendInterface
A contract for a cache backend which can be frozen.
Table of Contents
Methods
- collectGarbage() : mixed
- Does garbage collection
- flush() : mixed
- Removes all cache entries of this cache.
- freeze() : mixed
- Freezes this cache backend.
- get() : mixed
- Loads data from the cache.
- has() : bool
- Checks if a cache entry with the specified identifier exists.
- isFrozen() : bool
- Tells if this backend is frozen.
- remove() : bool
- Removes all cache entries matching the specified identifier.
- set() : mixed
- Saves data in the cache.
- setCache() : mixed
- Sets a reference to the cache frontend which uses this backend
Methods
collectGarbage()
Does garbage collection
public
collectGarbage() : mixed
flush()
Removes all cache entries of this cache.
public
flush() : mixed
freeze()
Freezes this cache backend.
public
freeze() : mixed
All data in a frozen backend remains unchanged and methods which try to add or modify data result in an exception thrown. Possible expiry times of individual cache entries are ignored.
On the positive side, a frozen cache backend is much faster on read access. A frozen backend can only be thawn by calling the flush() method.
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
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
isFrozen()
Tells if this backend is frozen.
public
isFrozen() : bool
Return values
boolremove()
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
set()
Saves data in the cache.
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. If the backend does not support tags, this option can be ignored.
- $lifetime : int = null
-
Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
Tags
setCache()
Sets a reference to the cache frontend which uses this backend
public
setCache(FrontendInterface $cache) : mixed
Parameters
- $cache : FrontendInterface
-
The frontend for this backend