CacheInterface
in
Covers most simple to advanced caching needs.
Tags
Table of Contents
- delete() : bool
- Removes an item from the pool.
- get() : mixed
- Fetches a value from the pool or computes it if not found.
Methods
delete()
Removes an item from the pool.
public
delete(string $key) : bool
Parameters
- $key : string
-
The key to delete
Tags
Return values
bool —True if the item was successfully removed, false if there was any error
get()
Fetches a value from the pool or computes it if not found.
public
get(string $key, callable|CallbackInterface $callback[, float|null $beta = null ][, array<string|int, mixed> &$metadata = null ]) : mixed
On cache misses, a callback is called that should return the missing value. This callback is given a PSR-6 CacheItemInterface instance corresponding to the requested key, that could be used e.g. for expiration control. It could also be an ItemInterface instance when its additional features are needed.
Parameters
- $key : string
-
The key of the item to retrieve from the cache
- $callback : callable|CallbackInterface
-
Should return the computed value for the given key/item
- $beta : float|null = null
-
A float that, as it grows, controls the likeliness of triggering early expiration. 0 disables it, INF forces immediate expiration. The default (or providing null) is implementation dependent but should typically be 1.0, which should provide optimal stampede protection. See https://en.wikipedia.org/wiki/Cache_stampede#Probabilistic_early_expiration
- $metadata : array<string|int, mixed> = null
-
The metadata of the cached item ItemInterface::getMetadata()