CacheItemPool
in package
implements
CacheItemPoolInterface
uses
ValidatesKey
PSR-6 cache item pool class
Tags
Table of Contents
Interfaces
- CacheItemPoolInterface
Properties
- $adapter : AdapterInterface
- Cache adapter
- $deferred : array<string|int, mixed>
- Deferred cache items, keyed by item key
Methods
- __construct() : mixed
- Constructor
- __destruct() : void
- Destructor
- clear() : bool
- Clear all stored values from cache
- commit() : bool
- Persist all deferred cache items
- deleteItem() : bool
- Delete an item from the cache
- deleteItems() : bool
- Delete multiple items from the cache
- getItem() : CacheItem
- Get a cache item by key
- getItems() : iterable<string|int, mixed>
- Get multiple cache items by their keys
- hasItem() : bool
- Determine if the cache contains an item for the given key
- save() : bool
- Persist a cache item immediately
- saveDeferred() : bool
- Queue a cache item to be persisted later
- validateKey() : void
- Validate a cache key (throws on reserved characters or an empty string)
Properties
$adapter
Cache adapter
protected
AdapterInterface
$adapter
$deferred
Deferred cache items, keyed by item key
protected
array<string|int, mixed>
$deferred
= []
Methods
__construct()
Constructor
public
__construct(AdapterInterface $adapter) : mixed
Instantiate the cache item pool object
Parameters
- $adapter : AdapterInterface
__destruct()
Destructor
public
__destruct() : void
Ensure any deferred cache items are persisted before the pool is destroyed, per PSR-6 §1.4 ("A Pool MUST ensure that any deferred cache items are eventually persisted"). A destructor must never let an exception escape, so failures here are swallowed.
clear()
Clear all stored values from cache
public
clear() : bool
Return values
boolcommit()
Persist all deferred cache items
public
commit() : bool
Return values
booldeleteItem()
Delete an item from the cache
public
deleteItem(string $key) : bool
Parameters
- $key : string
Tags
Return values
booldeleteItems()
Delete multiple items from the cache
public
deleteItems(array<string|int, mixed> $keys) : bool
Parameters
- $keys : array<string|int, mixed>
Tags
Return values
boolgetItem()
Get a cache item by key
public
getItem(string $key) : CacheItem
Parameters
- $key : string
Tags
Return values
CacheItemgetItems()
Get multiple cache items by their keys
public
getItems([array<string|int, mixed> $keys = [] ]) : iterable<string|int, mixed>
Parameters
- $keys : array<string|int, mixed> = []
Tags
Return values
iterable<string|int, mixed>hasItem()
Determine if the cache contains an item for the given key
public
hasItem(string $key) : bool
Parameters
- $key : string
Tags
Return values
boolsave()
Persist a cache item immediately
public
save(CacheItemInterface $item) : bool
A resolved expiration of zero or negative seconds deletes the item instead of caching it permanently, since the underlying adapter's saveItem() treats a TTL of 0 as "never expires" — the opposite of what an already-expired item should do.
Parameters
- $item : CacheItemInterface
Tags
Return values
boolsaveDeferred()
Queue a cache item to be persisted later
public
saveDeferred(CacheItemInterface $item) : bool
Parameters
- $item : CacheItemInterface
Tags
Return values
boolvalidateKey()
Validate a cache key (throws on reserved characters or an empty string)
protected
validateKey(string $key) : void
Parameters
- $key : string