FileAccess Orion

CacheItemPoolDecorator
in package
implements CacheItemPoolInterface Uses SerializationTrait

Decorate zend-cache adapters as PSR-6 cache item pools.

Tags
link
https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-6-cache.md
link
https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-6-cache-meta.md

Interfaces, Classes, Traits and Enums

CacheItemPoolInterface
CacheItemPoolInterface generates CacheItemInterface objects.

Table of Contents

$deferred  : array<string|int, CacheItem>
$storage  : StorageInterface
__construct()  : mixed
Constructor.
__destruct()  : mixed
Destructor.
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()  : array<string|int, mixed>|Traversable
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.
hasDeferredItem()  : bool
Returns true if deferred item exists for given key and has not expired
isSerializationRequired()  : bool
Determine if the given storage adapter requires serialization.
validateKey()  : mixed
Throws exception if given key is invalid
validateKeys()  : mixed
Throws exception if any of given keys is invalid
validateStorage()  : mixed
Throws exception is storage is not compatible with PSR-6

Properties

Methods

__construct()

Constructor.

public __construct(StorageInterface $storage) : mixed

PSR-6 requires that all implementing libraries support TTL so the given storage adapter must also support static TTL or an exception will be raised. Currently the following adapters do not support static TTL: Dba, Filesystem, Memory, Session and Redis < v2.

Parameters
$storage : StorageInterface
Tags
throws
CacheException
Return values
mixed

__destruct()

Destructor.

public __destruct() : mixed

Saves any deferred items that have not been committed

Return values
mixed

clear()

Deletes all items in the pool.

public clear() : bool

If the storage adapter supports namespaces and one has been set, only that namespace is cleared; otherwise entire cache is flushed.

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(mixed $key) : bool
Parameters
$key : mixed

The key to delete.

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, mixed> $keys) : bool
Parameters
$keys : array<string|int, mixed>

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

Return values
bool

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

getItems()

Returns a traversable set of cache items.

public getItems([array<string|int, mixed> $keys = [] ]) : array<string|int, mixed>|Traversable
Parameters
$keys : array<string|int, mixed> = []

An indexed array of keys of items to retrieve.

Return values
array<string|int, mixed>|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()

Confirms if the cache contains specified cache item.

public hasItem(mixed $key) : bool
Parameters
$key : mixed

The key for which to check existence.

Return values
bool

True if item exists in the cache, false otherwise.

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.

hasDeferredItem()

Returns true if deferred item exists for given key and has not expired

private hasDeferredItem(string $key) : bool
Parameters
$key : string
Return values
bool

validateKeys()

Throws exception if any of given keys is invalid

private validateKeys(array<string|int, mixed> $keys) : mixed
Parameters
$keys : array<string|int, mixed>
Tags
throws
InvalidArgumentException
Return values
mixed

Search results