CacheManager
final class CacheManager (View source)
Provides cache-aside convenience operations over one PSR-6 cache pool.
The manager keeps no cache state of its own and delegates persistence and invalidation to the pool.
Methods
Binds convenience operations to the pool that owns cached state.
Exposes the underlying pool for operations outside the manager's convenience API.
Returns a cached value or computes and stores it with the requested lifetime.
Returns a cached value or computes and stores it without expiration.
Returns the cached value for a hit and the supplied default for a miss.
Stores a value and clears expiration with null or clamps a non-positive lifetime to immediate expiry.
Reports whether the underlying pool contains a live item for the key.
Removes one key through the underlying pool.
Removes all entries owned by the underlying pool.
Details
__construct
__construct(CacheItemPoolInterface $pool)
Binds convenience operations to the pool that owns cached state.
pool
CacheItemPoolInterface
pool()
Exposes the underlying pool for operations outside the manager's convenience API.
remember
mixed
remember(string $key, int|null $ttlSeconds, callable $callback)
Returns a cached value or computes and stores it with the requested lifetime.
rememberForever
mixed
rememberForever(string $key, callable $callback)
Returns a cached value or computes and stores it without expiration.
get
mixed
get(string $key, mixed $default = null)
Returns the cached value for a hit and the supplied default for a miss.
put
bool
put(string $key, mixed $value, int|null $ttlSeconds = null)
Stores a value and clears expiration with null or clamps a non-positive lifetime to immediate expiry.
has
bool
has(string $key)
Reports whether the underlying pool contains a live item for the key.
forget
bool
forget(string $key)
Removes one key through the underlying pool.
clear
bool
clear()
Removes all entries owned by the underlying pool.