class Cache implements CacheInterface, ArrayAccess (View source)

Class Cache

Methods

__construct(CacheItemPoolInterface $storage = null, SerializerInterface $serializer = null)

Class init.

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

boolean
clear()

This will wipe out the entire cache's keys

array
getMultiple(array $keys)

Obtain multiple CacheItems by their unique keys

setMultiple(array $items, int|null $ttl = null)

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

mixed
call(string $key, callable $callable)

Fetch data from a callback if item not exists.

CacheItemPoolInterface
getStorage()

getStorage

setStorage(CacheItemPoolInterface $storage)

setStorage

bool
exists(string $key)

exists

setSerializer(SerializerInterface $serializer)

setHandler

boolean
offsetExists(mixed $offset)

Is a property exists or not.

mixed
offsetGet(mixed $offset)

Get a property.

void
offsetSet(mixed $offset, mixed $value)

Set a value to property.

void
offsetUnset(mixed $offset)

Unset a property.

Details

at line line 45
__construct(CacheItemPoolInterface $storage = null, SerializerInterface $serializer = null)

Class init.

Parameters

CacheItemPoolInterface $storage
SerializerInterface $serializer

at line line 61
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 83
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 101
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 113
boolean clear()

This will wipe out the entire cache's keys

Return Value

boolean The result of the empty operation

at line line 126
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 140
CacheInterface setMultiple(array $items, int|null $ttl = null)

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

CacheInterface Return self to support chaining.

at line line 157
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 173
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 201
CacheItemPoolInterface getStorage()

getStorage

Return Value

CacheItemPoolInterface

at line line 213
Cache setStorage(CacheItemPoolInterface $storage)

setStorage

Parameters

CacheItemPoolInterface $storage

Return Value

Cache Return self to support chaining.

at line line 227
bool exists(string $key)

exists

Parameters

string $key

Return Value

bool

at line line 237
SerializerInterface getSerializer()

getHandler

Return Value

SerializerInterface

at line line 249
Cache setSerializer(SerializerInterface $serializer)

setHandler

Parameters

SerializerInterface $serializer

Return Value

Cache Return self to support chaining.

at line line 263
boolean offsetExists(mixed $offset)

Is a property exists or not.

Parameters

mixed $offset Offset key.

Return Value

boolean

at line line 276
mixed offsetGet(mixed $offset)

Get a property.

Parameters

mixed $offset Offset key.

Return Value

mixed The value to return.

Exceptions

InvalidArgumentException

at line line 290
void offsetSet(mixed $offset, mixed $value)

Set a value to property.

Parameters

mixed $offset Offset key.
mixed $value The value to set.

Return Value

void

Exceptions

InvalidArgumentException

at line line 303
void offsetUnset(mixed $offset)

Unset a property.

Parameters

mixed $offset Offset key to unset.

Return Value

void

Exceptions

InvalidArgumentException