interface CacheInterface (View source)

Interface CacheInterface

Methods

CacheItemInterface
get(string $key)

Here we pass in a cache key to be fetched from the cache.

CacheItemInterface
set(string $key, mixed $val, int|null $ttl = null)

Persisting our data in the cache, uniquely referenced by a key with an optional expiration TTL time.

remove(string $key)

Remove an item from the cache by its unique key

mixed
call(string $key, callable $callable)

Fetch data from a callback if item not exists.

array
getMultiple(array $keys)

Obtain multiple CacheItems by their unique keys

setMultiple(array $items)

Persisting a set of key => value pairs in the cache, with an optional TTL.

removeMultiple(array $keys)

Remove multiple cache items in a single operation

boolean
clear()

This will wipe out the entire cache's keys

bool
exists(string $key)

exists

Details

at line line 20
CacheItemInterface get(string $key)

Here we pass in a cache key to be fetched from the cache.

A CacheItem object will be constructed and returned to us

Parameters

string $key The unique key of this item in the cache

Return Value

CacheItemInterface The newly populated CacheItem class representing the stored data in the cache

at line line 32
CacheItemInterface set(string $key, mixed $val, int|null $ttl = null)

Persisting our data in the cache, uniquely referenced by a key with an optional expiration TTL time.

Parameters

string $key The key of the item to store
mixed $val The value of the item to store
int|null $ttl Optional. The TTL value of this item. If no value is sent and the driver supports TTL then the library may set a default value for it or let the driver take care of that.

Return Value

CacheItemInterface Return CacheItem to chaining.

at line line 41
CacheInterface remove(string $key)

Remove an item from the cache by its unique key

Parameters

string $key The unique cache key of the item to remove

Return Value

CacheInterface

at line line 52
mixed call(string $key, callable $callable)

Fetch data from a callback if item not exists.

Parameters

string $key The key of the item to fetch.
callable $callable The callback to fetch data.

Return Value

mixed

Exceptions

InvalidArgumentException

at line line 62
array getMultiple(array $keys)

Obtain multiple CacheItems by their unique keys

Parameters

array $keys A list of keys that can obtained in a single operation.

Return Value

array An array of CacheItem classes. The resulting array must use the CacheItem's key as the associative key for the array.

at line line 74
CacheInterface setMultiple(array $items)

Persisting a set of key => value pairs in the cache, with an optional TTL.

Parameters

array $items An array of key => value pairs for a multiple-set operation.

Return Value

CacheInterface Return self to support chaining.

at line line 83
CacheInterface removeMultiple(array $keys)

Remove multiple cache items in a single operation

Parameters

array $keys The array of keys to be removed

Return Value

CacheInterface Return self to support chaining.

at line line 90
boolean clear()

This will wipe out the entire cache's keys

Return Value

boolean The result of the empty operation

at line line 99
bool exists(string $key)

exists

Parameters

string $key

Return Value

bool