interface FrontendInterface (View source)

Contract for a Cache (frontend)

Constants

PATTERN_ENTRYIDENTIFIER

Pattern an entry identifier must match.

PATTERN_TAG

Pattern a tag must match.

Methods

string
getIdentifier()

Returns this cache's identifier

getBackend()

Returns the backend used by this cache

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

Saves data in the cache.

mixed
get(string $entryIdentifier)

Finds and returns data from the cache.

array
getByTag(string $tag)

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

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.

Details

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

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

Saves data in the cache.

Parameters

string $entryIdentifier

Something which identifies the data - depends on concrete cache

mixed $data

The data to cache - also depends on the concrete cache implementation

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

mixed get(string $entryIdentifier)

Finds and returns data from the cache.

Parameters

string $entryIdentifier

Something which identifies the cache entry - depends on concrete cache

Return Value

mixed

The value or false if the cache entry could not be loaded

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

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 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

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

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

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