class TaggableMultiBackend extends MultiBackend implements TaggableBackendInterface (View source)

A taggable multi backend, falling back to multiple backends if errors occur.

Traits

Abstracts the task of creating a BackendInterface implementation with it's options.

Constants

DATETIME_EXPIRYTIME_UNLIMITED

UNLIMITED_LIFETIME

Properties

protected FrontendInterface $cache

Reference to the cache frontend which uses this backend

from  AbstractBackend
protected string $cacheIdentifier from  AbstractBackend
protected string $identifierPrefix

A prefix to seperate stored by appliaction context and cache

from  AbstractBackend
protected int $defaultLifetime

Default lifetime of a cache entry in seconds

from  AbstractBackend
protected EnvironmentConfiguration $environmentConfiguration from  AbstractBackend
protected $backendConfigurations from  MultiBackend
protected $backends from  MultiBackend
protected $setInAllBackends from  MultiBackend
protected $debug from  MultiBackend
protected $logErrors from  MultiBackend
protected $removeUnhealthyBackends from  MultiBackend
protected $initialized from  MultiBackend
protected $logger from  MultiBackend
protected $throwableStorage from  MultiBackend

Methods

__construct(EnvironmentConfiguration $environmentConfiguration = null, array $options = [])

Constructs this backend

void
setProperties(array $properties, bool $throwExceptionIfPropertyNotSettable = true)

No description

bool
setProperty(string $propertyName, mixed $propertyValue)

No description

void
setCache(FrontendInterface $cache)

Sets a reference to the cache frontend which uses this backend

void
setDefaultLifetime(int|string $defaultLifetime)

Sets the default lifetime for this cache backend

calculateExpiryTime(int $lifetime = null)

Calculates the expiry time by the given lifetime. If no lifetime is specified, the default lifetime is used.

string
getPrefixedIdentifier(string $entryIdentifier)

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

instantiateBackend(string $backendObjectName, array $backendOptions, EnvironmentConfiguration $environmentConfiguration)

No description

void
prepareBackends()

No description

BackendInterface|null
buildSubBackend(string $backendClassName, array $backendOptions)

No description

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

No description

mixed
get(string $entryIdentifier)

No description

bool
has(string $entryIdentifier)

No description

bool
remove(string $entryIdentifier)

No description

void
flush()

No description

void
collectGarbage()

No description

void
setBackendConfigurations(array $backendConfigurations)

This setter is used by AbstractBackend::setProperties()

void
setSetInAllBackends(bool $setInAllBackends)

This setter is used by AbstractBackend::setProperties()

void
setDebug(bool $debug)

This setter is used by AbstractBackend::setProperties()

void
setRemoveUnhealthyBackends(bool $removeUnhealthyBackends)

This setter is used by AbstractBackend::setProperties()

void
setLogErrors(bool $logErrors)

This setter is used by AbstractBackend::setProperties()

void
handleError(Throwable $throwable)

No description

void
removeUnhealthyBackend(BackendInterface $unhealthyBackend)

No description

int
flushByTag(string $tag)

No description

int
flushByTags(array $tags)

No description

array
findIdentifiersByTag(string $tag)

No description

Details

__construct(EnvironmentConfiguration $environmentConfiguration = null, array $options = [])

Constructs this backend

Parameters

EnvironmentConfiguration $environmentConfiguration
array $options

Configuration options - depends on the actual backend

protected void setProperties(array $properties, bool $throwExceptionIfPropertyNotSettable = true)

No description

Parameters

array $properties
bool $throwExceptionIfPropertyNotSettable

Return Value

void

Exceptions

InvalidArgumentException

protected bool setProperty(string $propertyName, mixed $propertyValue)

No description

Parameters

string $propertyName
mixed $propertyValue

Return Value

bool

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

void setDefaultLifetime(int|string $defaultLifetime)

Sets the default lifetime for this cache backend

Parameters

int|string $defaultLifetime

Default lifetime of this cache backend in seconds. 0 means unlimited lifetime.

Return Value

void

Exceptions

InvalidArgumentException

protected DateTime calculateExpiryTime(int $lifetime = null)

Calculates the expiry time by the given lifetime. If no lifetime is specified, the default lifetime is used.

Parameters

int $lifetime

The lifetime in seconds

Return Value

DateTime

The expiry time

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.

Note that, in case of the AbstractBackend, this method is returns just the given entry identifier.

Parameters

string $entryIdentifier

Return Value

string

protected BackendInterface instantiateBackend(string $backendObjectName, array $backendOptions, EnvironmentConfiguration $environmentConfiguration)

No description

Parameters

string $backendObjectName
array $backendOptions
EnvironmentConfiguration $environmentConfiguration

Return Value

BackendInterface

Exceptions

InvalidBackendException

protected void prepareBackends()

No description

Return Value

void

Exceptions

Throwable

protected BackendInterface|null buildSubBackend(string $backendClassName, array $backendOptions)

No description

Parameters

string $backendClassName
array $backendOptions

Return Value

BackendInterface|null

Exceptions

Throwable

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

No description

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

Throwable

mixed get(string $entryIdentifier)

No description

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

Exceptions

Throwable

bool has(string $entryIdentifier)

No description

Parameters

string $entryIdentifier

An identifier specifying the cache entry

Return Value

bool

true if such an entry exists, false if not

Exceptions

Throwable

bool remove(string $entryIdentifier)

No description

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

Exceptions

Throwable

void flush()

No description

Return Value

void

Exceptions

Throwable

void collectGarbage()

No description

Return Value

void

Exceptions

Throwable

protected void setBackendConfigurations(array $backendConfigurations)

This setter is used by AbstractBackend::setProperties()

Parameters

array $backendConfigurations

Return Value

void

protected void setSetInAllBackends(bool $setInAllBackends)

This setter is used by AbstractBackend::setProperties()

Parameters

bool $setInAllBackends

Return Value

void

protected void setDebug(bool $debug)

This setter is used by AbstractBackend::setProperties()

Parameters

bool $debug

Return Value

void

void setRemoveUnhealthyBackends(bool $removeUnhealthyBackends)

This setter is used by AbstractBackend::setProperties()

Parameters

bool $removeUnhealthyBackends

Return Value

void

void setLogErrors(bool $logErrors)

This setter is used by AbstractBackend::setProperties()

Parameters

bool $logErrors

Return Value

void

protected void handleError(Throwable $throwable)

No description

Parameters

Throwable $throwable

Return Value

void

Exceptions

Throwable

protected void removeUnhealthyBackend(BackendInterface $unhealthyBackend)

No description

Parameters

BackendInterface $unhealthyBackend

Return Value

void

int flushByTag(string $tag)

No description

Parameters

string $tag

The tag the entries must have

Return Value

int

The number of entries which have been affected by this flush

Exceptions

Throwable

int flushByTags(array $tags)

No description

Parameters

array $tags

The tags the entries must have

Return Value

int

The number of entries which have been affected by this flush

Exceptions

Throwable

array findIdentifiersByTag(string $tag)

No description

Parameters

string $tag

The tag to search for

Return Value

array

An array with identifiers of all matching entries. An empty array if no entries matched

Exceptions

Throwable