class SimpleCache implements CacheInterface (View source)

A simple cache frontend Note: This does not follow the \Neos\Cache\Frontend\FrontendInterface this package provides.

Constants

PATTERN_ENTRYIDENTIFIER

Pattern an entry identifier must match.

Properties

protected string $identifier
protected BackendInterface $backend

Methods

__construct(string $identifier, BackendInterface $backend)

Constructs the cache

bool
set(string $key, mixed $value, null|int|DateInterval $ttl = null)

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

mixed
get(string $key, mixed $default = null)

Finds and returns a variable value from the cache.

bool
delete(string $key)

No description

bool
clear()

No description

iterable
getMultiple(iterable $keys, mixed $default = null)

No description

bool
setMultiple(iterable $values, null|int|DateInterval $ttl = null)

No description

bool
deleteMultiple(iterable $keys)

No description

bool
has(string $key)

No description

bool
isValidEntryIdentifier(string $key)

No description

void
ensureValidEntryIdentifier(string $key)

No description

Details

__construct(string $identifier, BackendInterface $backend)

Constructs the cache

Parameters

string $identifier

A identifier which describes this cache

BackendInterface $backend

Backend to be used for this cache

Exceptions

InvalidArgumentException

bool set(string $key, mixed $value, null|int|DateInterval $ttl = null)

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

Parameters

string $key

An identifier used for this cache entry

mixed $value

The variable to cache

null|int|DateInterval $ttl

Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" or negative integers are treted as delete

Return Value

bool

Exceptions

Exception
InvalidArgumentException

mixed get(string $key, mixed $default = null)

Finds and returns a variable value from the cache.

Parameters

string $key

Identifier of the cache entry to fetch

mixed $default

Return Value

mixed

The value or the defaultValue if entry was not found

Exceptions

Exception
InvalidArgumentException

bool delete(string $key)

No description

Parameters

string $key

Return Value

bool

Exceptions

Exception
InvalidArgumentException

bool clear()

No description

Return Value

bool

iterable getMultiple(iterable $keys, mixed $default = null)

No description

Parameters

iterable $keys
mixed $default

Return Value

iterable

Exceptions

InvalidArgumentException
Exception

bool setMultiple(iterable $values, null|int|DateInterval $ttl = null)

No description

Parameters

iterable $values
null|int|DateInterval $ttl

Return Value

bool

Exceptions

Exception
InvalidArgumentException

bool deleteMultiple(iterable $keys)

No description

Parameters

iterable $keys

Return Value

bool

Exceptions

InvalidArgumentException
Exception

bool has(string $key)

No description

Parameters

string $key

Return Value

bool

Exceptions

InvalidArgumentException

protected bool isValidEntryIdentifier(string $key)

No description

Parameters

string $key

Return Value

bool

protected void ensureValidEntryIdentifier(string $key)

No description

Parameters

string $key

Return Value

void

Exceptions

InvalidArgumentException

protected int calculateLifetimeFromDateInterval(DateInterval $ttl)

No description

Parameters

DateInterval $ttl

Return Value

int