Basicis - Core

Logo

As the name says, it is made to be basic and direct.

View the Project on GitHub basicis/core

Basicis\Cache\CacheItemPool

CacheItemPool 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.

Implements:

Psr\Cache\CacheItemPoolInterface

Methods

Name Description
__construct Function __construct
Receives a cacheFile path as param or null  
addItem Function addItem
Adding a chache item  
checkExpiredItems Function checkExpiredItems
Check if items on is hitable and remove  
clear Function clear
Deletes all items in the pool.  
commit Function commit
Persists any deferred cache items.  
deleteItem Funtion deleteItem
Removes the item from the pool.  
deleteItems Function deleteItems
Removes multiple items from the pool.  
getFile Function getFile
Get this pool file path  
getItem Function getItem
Returns a Cache Item representing the specified key.  
getItems Function getItems
Returns a traversable set of cache items.  
hasItem Function hasItem
Confirms if the cache contains specified cache item.  
load Function load
Load a saved cache pool by stream and return this loaded, or return this current object  
save Function save
Persists a cache item immediately.  
saveDeferred Function saveDeferred
Sets a cache item to be persisted later.  
serialize Function serialize
Serialize this pool  
setFile Function setFile
Set this cache pool file  
unserialize Function unserialize
Unserialize this pool  
withItem Function withItem
With a Added chache item  

CacheItemPool::__construct

Description

public __construct (string|null $cacheFile)

Function __construct Receives a cacheFile path as param or null

Parameters

Return Values

void


CacheItemPool::addItem

Description

public addItem (string $key, mixed $value, \DateTimeInterface|null $expiration, int|string|\DateIntervalInterface|null $time)

Function addItem Adding a chache item

Parameters

Return Values

void


CacheItemPool::checkExpiredItems

Description

public checkExpiredItems (void)

Function checkExpiredItems Check if items on is hitable and remove

Parameters

This function has no parameters.

Return Values

\CacheItemPool


CacheItemPool::clear

Description

public clear (void)

Function clear Deletes all items in the pool.

Parameters

This function has no parameters.

Return Values

bool

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


CacheItemPool::commit

Description

public commit (void)

Function commit Persists any deferred cache items.

Parameters

This function has no parameters.

Return Values

bool

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


CacheItemPool::deleteItem

Description

public deleteItem (string $key)

Funtion deleteItem Removes the item from the pool.

Parameters

Return Values

bool

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

Throws Exceptions

\InvalidArgumentException

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


CacheItemPool::deleteItems

Description

public deleteItems (string[]|array $keys)

Function deleteItems Removes multiple items from the pool.

Parameters

Return Values

bool

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

Throws Exceptions

\InvalidArgumentException

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


CacheItemPool::getFile

Description

public getFile (void)

Function getFile Get this pool file path

Parameters

This function has no parameters.

Return Values

string


CacheItemPool::getItem

Description

public getItem (string $key)

Function getItem 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

Return Values

\CacheItemInterface

The corresponding Cache Item.

Throws Exceptions

\InvalidArgumentException

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


CacheItemPool::getItems

Description

public getItems (string[] $keys)

Function getItems Returns a traversable set of cache items.

Parameters

Return Values

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.

Throws Exceptions

\InvalidArgumentException

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


CacheItemPool::hasItem

Description

public hasItem (string $key)

Function hasItem 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

Return Values

bool

True if item exists in the cache, false otherwise.

Throws Exceptions

\InvalidArgumentException

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


CacheItemPool::load

Description

public load (\CacheItemInterface $item)

Function load Load a saved cache pool by stream and return this loaded, or return this current object

Parameters

Return Values

bool

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


CacheItemPool::save

Description

public save (\CacheItemInterface $item)

Function save Persists a cache item immediately.

Parameters

Return Values

bool

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


CacheItemPool::saveDeferred

Description

public saveDeferred (\CacheItemInterface $item)

Function saveDeferred Sets a cache item to be persisted later.

Parameters

Return Values

bool

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


CacheItemPool::serialize

Description

public serialize (void)

Function serialize Serialize this pool

Parameters

This function has no parameters.

Return Values

string


CacheItemPool::setFile

Description

public setFile (void)

Function setFile Set this cache pool file

Parameters

This function has no parameters.

Return Values

string


CacheItemPool::unserialize

Description

public unserialize (string $pool)

Function unserialize Unserialize this pool

Parameters

Return Values

\CacheItemPool


CacheItemPool::withItem

Description

public withItem (string $key, \CacheItemInterface|mixed $value, \DateTimeInterface|null $expiration, int|string|\DateIntervalInterface|null $time)

Function withItem With a Added chache item

Parameters

Return Values

void