interface FreezableBackendInterface implements BackendInterface (View source)

A contract for a cache backend which can be frozen.

Methods

void
setCache(FrontendInterface $cache)

Sets a reference to the cache frontend which uses this backend

string
getPrefixedIdentifier(string $entryIdentifier)

Returns the internally used, prefixed entry identifier for the given public entry identifier.

void
set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null)

Saves data in the cache.

mixed
get(string $entryIdentifier)

Loads data from the cache.

bool
has(string $entryIdentifier)

Checks if a cache entry with the specified identifier exists.

bool
remove(string $entryIdentifier)

Removes all cache entries matching the specified identifier.

void
flush()

Removes all cache entries of this cache.

void
collectGarbage()

Does garbage collection

void
freeze()

Freezes this cache backend.

bool
isFrozen()

Tells if this backend is frozen.

Details

void setCache(FrontendInterface $cache)

Sets a reference to the cache frontend which uses this backend

Parameters

FrontendInterface $cache

The frontend for this backend

Return Value

void

string getPrefixedIdentifier(string $entryIdentifier)

Returns the internally used, prefixed entry identifier for the given public entry identifier.

While Flow applications will mostly refer to the simple entry identifier, it may be necessary to know the actual identifier used by the cache backend in order to share cache entries with other applications. This method allows for retrieving it.

Parameters

string $entryIdentifier

Return Value

string

void set(string $entryIdentifier, string $data, array $tags = [], int $lifetime = null)

Saves data in the cache.

Parameters

string $entryIdentifier

An identifier for this specific cache entry

string $data

The data to be stored

array $tags

Tags to associate with this cache entry. If the backend does not support tags, this option can be ignored.

int $lifetime

Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.

Return Value

void

Exceptions

Exception
InvalidArgumentException

mixed get(string $entryIdentifier)

Loads data from the cache.

Parameters

string $entryIdentifier

An identifier which describes the cache entry to load

Return Value

mixed

The cache entry's content as a string or false if the cache entry could not be loaded

bool has(string $entryIdentifier)

Checks if a cache entry with the specified identifier exists.

Parameters

string $entryIdentifier

An identifier specifying the cache entry

Return Value

bool

true if such an entry exists, false if not

bool remove(string $entryIdentifier)

Removes all cache entries matching the specified identifier.

Usually this only affects one entry but if - for what reason ever - old entries for the identifier still exist, they are removed as well.

Parameters

string $entryIdentifier

Specifies the cache entry to remove

Return Value

bool

true if (at least) an entry could be removed or false if no entry was found

void flush()

Removes all cache entries of this cache.

Return Value

void

void collectGarbage()

Does garbage collection

Return Value

void

void freeze()

Freezes this cache backend.

All data in a frozen backend remains unchanged and methods which try to add or modify data result in an exception thrown. Possible expiry times of individual cache entries are ignored.

On the positive side, a frozen cache backend is much faster on read access. A frozen backend can only be thawed by calling the flush() method.

Return Value

void

bool isFrozen()

Tells if this backend is frozen.

Return Value

bool