class CachePool implements CacheItemPoolInterface (View source)

An implementation of the CacheItemPoolInterface from the PSR-6 specification to be used with our provided backends.

Constants

PATTERN_ENTRYIDENTIFIER

Pattern an entry identifier must match.

Properties

protected BackendInterface $backend
protected string $identifier

An identifier for this cache, useful if you use several different caches.

protected array $deferredItems

A list of items still to be persisted.

Methods

__construct(string $identifier, BackendInterface $backend)

Constructs the cache

CacheItemInterface
getItem(string $key)

Returns a Cache Item representing the specified key.

array
getItems(array $keys = [])

Returns a traversable set of cache items.

bool
hasItem(string $key)

Confirms if the cache contains specified cache item.

bool
clear()

Deletes all items in the pool.

bool
deleteItem(string $key)

Removes the item from the pool.

bool
deleteItems(array $keys)

Removes multiple items from the pool.

bool
save(CacheItemInterface $item)

Persists a cache item immediately.

bool
saveDeferred(CacheItemInterface $item)

Sets a cache item to be persisted later.

bool
commit()

Persists any deferred cache items.

bool
isValidEntryIdentifier(string $identifier)

Checks the validity of an entry identifier. Returns true if it's valid.

Details

__construct(string $identifier, BackendInterface $backend)

Constructs the cache

Parameters

string $identifier

A identifier which describes this cache

BackendInterface $backend

Backend to be used for this cache

Exceptions

InvalidArgumentException

CacheItemInterface getItem(string $key)

Returns a Cache Item representing the specified key.

Parameters

string $key

Return Value

CacheItemInterface

Exceptions

InvalidArgumentException

array getItems(array $keys = [])

Returns a traversable set of cache items.

Parameters

array $keys

Return Value

array

Exceptions

InvalidArgumentException

bool hasItem(string $key)

Confirms if the cache contains specified cache item.

Parameters

string $key

Return Value

bool

Exceptions

InvalidArgumentException

bool clear()

Deletes all items in the pool.

Return Value

bool

bool deleteItem(string $key)

Removes the item from the pool.

Parameters

string $key

Return Value

bool

Exceptions

InvalidArgumentException

bool deleteItems(array $keys)

Removes multiple items from the pool.

Parameters

array $keys

Return Value

bool

Exceptions

InvalidArgumentException

bool save(CacheItemInterface $item)

Persists a cache item immediately.

Parameters

CacheItemInterface $item

Return Value

bool

Exceptions

Exception

bool saveDeferred(CacheItemInterface $item)

Sets a cache item to be persisted later.

Parameters

CacheItemInterface $item

Return Value

bool

bool commit()

Persists any deferred cache items.

Return Value

bool

Exceptions

Exception

bool isValidEntryIdentifier(string $identifier)

Checks the validity of an entry identifier. Returns true if it's valid.

Parameters

string $identifier

An identifier to be checked for validity

Return Value

bool