class FileCache implements FileCacheInterface (View source)

Allows to cache data based on file modification dates.

Properties

protected string $prefix

Prefix that is used for cache entries.

static protected array $cached

Static cache that contains already loaded cache entries.

protected string $collection

The collection identifier of this cache.

protected FileCacheBackendInterface $cache

The cache backend backing this FileCache object.

Methods

__construct(string $prefix, string $collection, string|null $cache_backend_class = NULL, array $cache_backend_configuration = [])

Constructs a FileCache object.

mixed|null
get(string $filepath)

Gets data based on a filename.

array
getMultiple(array $filepaths)

Gets data based on filenames.

set(string $filepath, mixed $data)

Stores data based on a filename.

delete(string $filepath)

Deletes data from the cache.

static 
reset()

Resets the static cache.

Details

__construct(string $prefix, string $collection, string|null $cache_backend_class = NULL, array $cache_backend_configuration = [])

Constructs a FileCache object.

Parameters

string $prefix

The cache prefix.

string $collection

A collection identifier to ensure that the same files could be cached for different purposes without clashing.

string|null $cache_backend_class

(optional) The class that should be used as cache backend.

array $cache_backend_configuration

(optional) The configuration for the backend class.

mixed|null get(string $filepath)

Gets data based on a filename.

Parameters

string $filepath

Path of the file that the cached data is based on.

Return Value

mixed|null

The data that was persisted with set() or NULL if there is no data or the file has been modified.

array getMultiple(array $filepaths)

Gets data based on filenames.

Parameters

array $filepaths

List of file paths used as cache identifiers.

Return Value

array

List of cached data keyed by the passed in file paths.

set(string $filepath, mixed $data)

Stores data based on a filename.

Parameters

string $filepath

Path of the file that the cached data is based on.

mixed $data

The data that should be cached.

delete(string $filepath)

Deletes data from the cache.

Parameters

string $filepath

Path of the file that the cached data is based on.

static reset()

Resets the static cache.

Replace this once https://www.drupal.org/node/2260187 is in.