class VariableFrontend extends AbstractFrontend (View source)

A cache frontend for any kinds of PHP variables

Properties

protected string $identifier

Identifies this cache

from  AbstractFrontend
protected BackendInterface $backend from  AbstractFrontend
protected bool $useIgBinary

If the extension "igbinary" is installed, use it for increased performance.

Methods

__construct(string $identifier, BackendInterface $backend)

Constructs the cache

void
initializeObject()

Initializes this cache frontend

string
getIdentifier()

Returns this cache's identifier

getBackend()

Returns the backend used by this cache

bool
has(string $entryIdentifier)

Checks if a cache entry with the specified identifier exists.

bool
remove(string $entryIdentifier)

Removes the given cache entry from the cache.

void
flush()

Removes all cache entries of this cache.

int
flushByTag(string $tag)

Removes all cache entries of this cache which are tagged by the specified tag.

int
flushByTags(array $tags)

Removes all cache entries of this cache which are tagged by any of the specified tags.

void
collectGarbage()

Does garbage collection

bool
isValidEntryIdentifier(string $identifier)

Checks the validity of an entry identifier. Returns true if it's valid.

bool
isValidTag(string $tag)

Checks the validity of a tag. Returns true if it's valid.

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

Saves the value of a PHP variable in the cache. Note that the variable will be serialized if necessary.

mixed
get(string $entryIdentifier)

Finds and returns a variable value from the cache.

array
getByTag(string $tag)

Finds and returns all cache entries which are tagged by the specified tag.

getIterator()

Returns an iterator over the entries of this cache

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

void initializeObject()

Initializes this cache frontend

Return Value

void

string getIdentifier()

Returns this cache's identifier

Return Value

string

The identifier for this cache

BackendInterface getBackend()

Returns the backend used by this cache

Return Value

BackendInterface

The backend used by this cache

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

Exceptions

InvalidArgumentException

bool remove(string $entryIdentifier)

Removes the given cache entry from the cache.

Parameters

string $entryIdentifier

An identifier specifying the cache entry

Return Value

bool

true if such an entry exists, false if not

Exceptions

InvalidArgumentException

void flush()

Removes all cache entries of this cache.

Return Value

void

int flushByTag(string $tag)

Removes all cache entries of this cache which are tagged by the specified tag.

Parameters

string $tag

The tag the entries must have

Return Value

int

The number of entries which have been affected by this flush

Exceptions

InvalidArgumentException

int flushByTags(array $tags)

Removes all cache entries of this cache which are tagged by any of the specified tags.

Parameters

array $tags

The tags the entries must have

Return Value

int

The number of entries which have been affected by this flush

Exceptions

InvalidArgumentException

void collectGarbage()

Does garbage collection

Return Value

void

bool isValidEntryIdentifier(string $identifier)

Checks the validity of an entry identifier. Returns true if it's valid.

Parameters

string $identifier

An identifier to be checked for validity

Return Value

bool

bool isValidTag(string $tag)

Checks the validity of a tag. Returns true if it's valid.

Parameters

string $tag

A tag to be checked for validity

Return Value

bool

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

Saves the value of a PHP variable in the cache. Note that the variable will be serialized if necessary.

Parameters

string $entryIdentifier

Something which identifies the data - depends on concrete cache

mixed $variable

The variable to cache

array $tags

Tags to associate with this cache entry

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

InvalidArgumentException
Exception

mixed get(string $entryIdentifier)

Finds and returns a variable value from the cache.

Parameters

string $entryIdentifier

Something which identifies the cache entry - depends on concrete cache

Return Value

mixed

Exceptions

InvalidArgumentException

array getByTag(string $tag)

Finds and returns all cache entries which are tagged by the specified tag.

Parameters

string $tag

The tag to search for

Return Value

array

An array with the identifier (key) and content (value) of all matching entries. An empty array if no entries matched

Exceptions

NotSupportedByBackendException
InvalidArgumentException

CacheEntryIterator getIterator()

Returns an iterator over the entries of this cache