Pool
in package
implements
CacheItemPoolInterface, LoggerAwareInterface
Uses
_Driver, KeyValidateTrait, LoggerTrait
The main cache manager
Interfaces, Classes, Traits and Enums
- CacheItemPoolInterface
- LoggerAwareInterface
Table of Contents
- __construct() : mixed
- Set up the cache backend
- clear() : bool
- Deletes all items in the pool.
- commit() : bool
- Persists any deferred cache items.
- deleteItem() : bool
- Removes the item from the pool.
- deleteItems() : bool
- Removes multiple items from the pool.
- getItem() : CacheItemInterface
- Returns a Cache Item representing the specified key.
- getItems() : iteratable<string|int, mixed>
- Returns a traversable set of cache items.
- hasItem() : bool
- Confirms if the cache contains specified cache item.
- save() : bool
- Persists a cache item immediately.
- saveDeferred() : bool
- Sets a cache item to be persisted later.
- setLogger() : void
- Set a logger to keep track of errors
Methods
__construct()
Set up the cache backend
public
__construct(array<string|int, mixed> $config[, LoggerInterface|null $logger = NULL ]) : mixed
Parameters
- $config : array<string|int, mixed>
- $logger : LoggerInterface|null = NULL
Return values
mixed —clear()
Deletes all items in the pool.
public
clear() : bool
Return values
bool —True if the pool was successfully cleared. False if there was an error.
commit()
Persists any deferred cache items.
public
commit() : bool
Return values
bool —True if all not-yet-saved items were successfully saved or there were none. False otherwise.
deleteItem()
Removes the item from the pool.
public
deleteItem(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 an error.
deleteItems()
Removes multiple items from the pool.
public
deleteItems(array<string|int, string> $keys) : bool
Parameters
- $keys : array<string|int, string>
-
An array of keys that should be removed from the pool.
Tags
Return values
bool —True if the items were successfully removed. False if there was an error.
getItem()
Returns a Cache Item representing the specified key.
public
getItem(string $key) : CacheItemInterface
This method must always return a CacheItemInterface object, even in case of a cache miss. It MUST NOT return null.
Parameters
- $key : string
-
The key for which to return the corresponding Cache Item.
Tags
Return values
CacheItemInterface —The corresponding Cache Item.
getItems()
Returns a traversable set of cache items.
public
getItems([array<string|int, string> $keys = [] ]) : iteratable<string|int, mixed>
Parameters
- $keys : array<string|int, string> = []
-
An indexed array of keys of items to retrieve.
Tags
Return values
iteratable<string|int, mixed> —A traversable collection of Cache Items keyed by the cache keys of each item. A Cache item will be returned for each key, even if that key is not found. However, if no keys are specified then an empty traversable MUST be returned instead.
hasItem()
Confirms if the cache contains specified cache item.
public
hasItem(string $key) : bool
Note: This method MAY avoid retrieving the cached value for performance reasons. This could result in a race condition with CacheItemInterface::get(). To avoid such situation use CacheItemInterface::isHit() instead.
Parameters
- $key : string
-
The key for which to check existence.
Tags
Return values
bool —True if item exists in the cache, false otherwise.
save()
Persists a cache item immediately.
public
save(CacheItemInterface $item) : bool
Parameters
- $item : CacheItemInterface
-
The cache item to save.
Return values
bool —True if the item was successfully persisted. False if there was an error.
saveDeferred()
Sets a cache item to be persisted later.
public
saveDeferred(CacheItemInterface $item) : bool
Parameters
- $item : CacheItemInterface
-
The cache item to save.
Return values
bool —False if the item could not be queued or if a commit was attempted and failed. True otherwise.
setLogger()
Set a logger to keep track of errors
public
setLogger(LoggerInterface $logger) : void
Parameters
- $logger : LoggerInterface