FileAccess Orion

SimpleCacheDecorator
in package
implements CacheInterface Uses SerializationTrait

Decorate a zend-cache storage adapter for usage as a PSR-16 implementation.

Interfaces, Classes, Traits and Enums

CacheInterface

Table of Contents

INVALID_KEY_CHARS  = ':@{}()/\\'
Characters reserved by PSR-16 that are not valid in cache keys.
$providesPerItemTtl  : bool
$storage  : StorageInterface
$success  : null|bool
Reference used by storage when calling getItem() to indicate status of operation.
$utc  : DateTimeZone
__construct()  : mixed
clear()  : bool
Wipes clean the entire cache's keys.
delete()  : bool
Delete an item from the cache by its unique key.
deleteMultiple()  : bool
Deletes multiple cache items in a single operation.
get()  : mixed
Fetches a value from the cache.
getMultiple()  : iteratable<string|int, mixed>
Obtains multiple cache items by their unique keys.
has()  : bool
Determines whether an item is present in the cache.
set()  : bool
Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
setMultiple()  : bool
Persists a set of key => value pairs in the cache, with an optional TTL.
convertIterableToArray()  : array<string|int, mixed>
convertTtlToInteger()  : null|int
isSerializationRequired()  : bool
Determine if the given storage adapter requires serialization.
memoizeTtlCapabilities()  : void
Determine if the storage adapter provides per-item TTL capabilities
translateException()  : SimpleCacheException
validateKey()  : void

Constants

INVALID_KEY_CHARS

Characters reserved by PSR-16 that are not valid in cache keys.

public mixed INVALID_KEY_CHARS = ':@{}()/\\'

Properties

$success

Reference used by storage when calling getItem() to indicate status of operation.

private null|bool $success

Methods

clear()

Wipes clean the entire cache's keys.

public clear() : bool
Return values
bool

True on success and false on failure.

delete()

Delete an item from the cache by its unique key.

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

The unique cache key of the item to delete.

Return values
bool

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

deleteMultiple()

Deletes multiple cache items in a single operation.

public deleteMultiple(mixed $keys) : bool
Parameters
$keys : mixed

A list of string-based keys to be deleted.

Return values
bool

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

get()

Fetches a value from the cache.

public get(mixed $key[, mixed $default = null ]) : mixed
Parameters
$key : mixed

The unique key of this item in the cache.

$default : mixed = null

Default value to return if the key does not exist.

Return values
mixed

The value of the item from the cache, or $default in case of cache miss.

getMultiple()

Obtains multiple cache items by their unique keys.

public getMultiple(mixed $keys[, mixed $default = null ]) : iteratable<string|int, mixed>
Parameters
$keys : mixed

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

$default : mixed = null

Default value to return for keys that do not exist.

Return values
iteratable<string|int, mixed>

A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value.

has()

Determines whether an item is present in the cache.

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

The cache item key.

Return values
bool

set()

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

public set(mixed $key, mixed $value[, mixed $ttl = null ]) : bool
Parameters
$key : mixed

The key of the item to store.

$value : mixed

The value of the item to store, must be serializable.

$ttl : mixed = null

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 values
bool

True on success and false on failure.

setMultiple()

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

public setMultiple(mixed $values[, mixed $ttl = null ]) : bool
Parameters
$values : mixed

A list of key => value pairs for a multiple-set operation.

$ttl : mixed = null

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 values
bool

True on success and false on failure.

convertIterableToArray()

private convertIterableToArray(array<string|int, mixed>|iteratable<string|int, mixed> $iterable, bool $useKeys, string $forMethod) : array<string|int, mixed>
Parameters
$iterable : array<string|int, mixed>|iteratable<string|int, mixed>
$useKeys : bool

Whether or not to preserve keys during conversion

$forMethod : string

Method that called this one; used for reporting invalid values.

Tags
throws
SimpleCacheInvalidArgumentException

for invalid $iterable values

Return values
array<string|int, mixed>

Search results