Documentation

ClosureCacheAdapter
in package
implements CacheAdapterInterface

Cache adapter that defers to closures for implementation

Interfaces, Classes and Traits

CacheAdapterInterface
Interface for cache adapters.

Table of Contents

$callables  : array<string|int, mixed>
__construct()  : mixed
The callables array is an array mapping the actions of the cache adapter to callables.
contains()  : bool
Test if an entry exists in the cache.
delete()  : bool
Deletes a cache entry.
fetch()  : string
Fetches an entry from the cache.
save()  : bool
Puts data into the cache.

Properties

$callables

protected array<string|int, mixed> $callables

Mapping of method names to callables

Methods

__construct()

The callables array is an array mapping the actions of the cache adapter to callables.

public __construct(array<string|int, mixed> $callables) : mixed
  • contains: Callable that accepts an $id and $options argument
  • delete: Callable that accepts an $id and $options argument
  • fetch: Callable that accepts an $id and $options argument
  • save: Callable that accepts an $id, $data, $lifeTime, and $options argument
Parameters
$callables : array<string|int, mixed>

array of action names to callable

Tags
throws
InvalidArgumentException

if the callable is not callable

Return values
mixed —

contains()

Test if an entry exists in the cache.

public contains(mixed $id[, array<string|int, mixed> $options = null ]) : bool
Parameters
$id : mixed

cache id The cache id of the entry to check for.

$options : array<string|int, mixed> = null

Array of cache adapter options

Return values
bool —

Returns TRUE if a cache entry exists for the given cache id, FALSE otherwise.

delete()

Deletes a cache entry.

public delete(mixed $id[, array<string|int, mixed> $options = null ]) : bool
Parameters
$id : mixed

cache id

$options : array<string|int, mixed> = null

Array of cache adapter options

Return values
bool —

TRUE on success, FALSE on failure

fetch()

Fetches an entry from the cache.

public fetch(mixed $id[, array<string|int, mixed> $options = null ]) : string
Parameters
$id : mixed

cache id The id of the cache entry to fetch.

$options : array<string|int, mixed> = null

Array of cache adapter options

Return values
string —

The cached data or FALSE, if no cache entry exists for the given id.

save()

Puts data into the cache.

public save(mixed $id, mixed $data[, mixed $lifeTime = false ][, array<string|int, mixed> $options = null ]) : bool
Parameters
$id : mixed

The cache id

$data : mixed

The cache entry/data

$lifeTime : mixed = false

The lifetime. If != false, sets a specific lifetime for this cache entry

$options : array<string|int, mixed> = null

Array of cache adapter options

Return values
bool —

TRUE if the entry was successfully stored in the cache, FALSE otherwise.

Search results