\Psr\CacheCacheItemPoolInterface

CacheItemPoolInterface generates CacheItemInterface objects.

The primary purpose of Cache\CacheItemPoolInterface is to accept a key from the Calling Library and return the associated Cache\CacheItemInterface object. It is also the primary point of interaction with the entire cache collection. All configuration and initialization of the Pool is left up to an Implementing Library.

Summary

Methods
Constants
getItem()
getItems()
hasItem()
clear()
deleteItem()
deleteItems()
save()
saveDeferred()
commit()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

getItem()

getItem(string  $key) : \Psr\Cache\CacheItemInterface

Returns a Cache Item representing the specified key.

This method must always return a CacheItemInterface object, even in case of a cache miss. It MUST NOT return null.

Parameters

string $key

The key for which to return the corresponding Cache Item.

Throws

\Psr\Cache\InvalidArgumentException

If the $key string is not a legal value a \Psr\Cache\InvalidArgumentException MUST be thrown.

Returns

\Psr\Cache\CacheItemInterface —

The corresponding Cache Item.

getItems()

getItems(string[]  $keys = array()) : array|\Traversable

Returns a traversable set of cache items.

Parameters

string[] $keys

An indexed array of keys of items to retrieve.

Throws

\Psr\Cache\InvalidArgumentException

If any of the keys in $keys are not a legal value a \Psr\Cache\InvalidArgumentException MUST be thrown.

Returns

array|\Traversable —

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()

hasItem(string  $key) : bool

Confirms if the cache contains specified cache item.

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

string $key

The key for which to check existence.

Throws

\Psr\Cache\InvalidArgumentException

If the $key string is not a legal value a \Psr\Cache\InvalidArgumentException MUST be thrown.

Returns

bool —

True if item exists in the cache, false otherwise.

clear()

clear() : bool

Deletes all items in the pool.

Returns

bool —

True if the pool was successfully cleared. False if there was an error.

deleteItem()

deleteItem(string  $key) : bool

Removes the item from the pool.

Parameters

string $key

The key to delete.

Throws

\Psr\Cache\InvalidArgumentException

If the $key string is not a legal value a \Psr\Cache\InvalidArgumentException MUST be thrown.

Returns

bool —

True if the item was successfully removed. False if there was an error.

deleteItems()

deleteItems(string[]  $keys) : bool

Removes multiple items from the pool.

Parameters

string[] $keys

An array of keys that should be removed from the pool.

Throws

\Psr\Cache\InvalidArgumentException

If any of the keys in $keys are not a legal value a \Psr\Cache\InvalidArgumentException MUST be thrown.

Returns

bool —

True if the items were successfully removed. False if there was an error.

save()

save(\Psr\Cache\CacheItemInterface  $item) : bool

Persists a cache item immediately.

Parameters

\Psr\Cache\CacheItemInterface $item

The cache item to save.

Returns

bool —

True if the item was successfully persisted. False if there was an error.

saveDeferred()

saveDeferred(\Psr\Cache\CacheItemInterface  $item) : bool

Sets a cache item to be persisted later.

Parameters

\Psr\Cache\CacheItemInterface $item

The cache item to save.

Returns

bool —

False if the item could not be queued or if a commit was attempted and failed. True otherwise.

commit()

commit() : bool

Persists any deferred cache items.

Returns

bool —

True if all not-yet-saved items were successfully saved or there were none. False otherwise.