class JSONCache extends FileCache (View source)

deprecated

JSON cache storage backend.

Constants

EXTENSION

Properties

protected $bin from FileCache

Methods

__construct($bin)

Constructor.

from FileCache
cacheDirectory(string $bin = null)

Returns the cache directory for the given bin.

from FileCache
The
get(string $cid)

Return data from the persistent cache.

from FileCache
An
getMultiple(array $cids)

Return data from the persistent cache when given an array of cache IDs.

from FileCache
readFile(string $filename)

Returns the contents of the given filename unserialized.

set(string $cid, array $data, $expire = DRUSH_CACHE_PERMANENT)

Store data in the persistent cache.

from FileCache
writeFile(string $filename, $cache)

Serializes data and write it to the given filename.

clear(string $cid = null, bool $wildcard = false)

Expire data from the cache. If called without arguments, expirable entries will be cleared from all known cache bins.

from FileCache
TRUE
isEmpty()

Check if a cache bin is empty.

from FileCache
The
getFilePath($cid)

Converts a cache id to a full path.

from FileCache

Details

__construct($bin)

Constructor.

Parameters

$bin The cache bin for which the object is created.

cacheDirectory(string $bin = null)

Returns the cache directory for the given bin.

Parameters

string $bin

The get(string $cid)

Return data from the persistent cache.

Parameters

string $cid The cache ID of the data to retrieve.

Return Value

The cache or FALSE on failure.

An getMultiple(array $cids)

Return data from the persistent cache when given an array of cache IDs.

Parameters

array $cids An array of cache IDs for the data to retrieve. This is passed by reference, and will have the IDs successfully returned from cache removed.

Return Value

An array of the items successfully returned from cache indexed by cid.

readFile(string $filename)

Returns the contents of the given filename unserialized.

Parameters

string $filename Absolute path to filename to read contents from.

set(string $cid, array $data, $expire = DRUSH_CACHE_PERMANENT)

Store data in the persistent cache.

Parameters

string $cid The cache ID of the data to store.
array $data The data to store in the cache.
$expire One of the following values: - DRUSH_CACHE_PERMANENT: Indicates that the item should never be removed unless explicitly told to using _drush_cache_clear_all() with a cache ID. - DRUSH_CACHE_TEMPORARY: Indicates that the item should be removed at the next general cache wipe. - A Unix timestamp: Indicates that the item should be kept at least until the given time, after which it behaves like CACHE_TEMPORARY.

writeFile(string $filename, $cache)

Serializes data and write it to the given filename.

Parameters

string $filename Absolute path to filename to write cache data.
$cache Cache data to serialize and write to $filename.

clear(string $cid = null, bool $wildcard = false)

Expire data from the cache. If called without arguments, expirable entries will be cleared from all known cache bins.

Parameters

string $cid If set, the cache ID to delete. Otherwise, all cache entries that can expire are deleted.
bool $wildcard If set to TRUE, the $cid is treated as a substring to match rather than a complete ID. The match is a right hand match. If '*' is given as $cid, the bin $bin will be emptied.

TRUE isEmpty()

Check if a cache bin is empty.

A cache bin is considered empty if it does not contain any valid data for any cache ID.

Return Value

TRUE if the cache bin specified is empty.

protected The getFilePath($cid)

Converts a cache id to a full path.

Parameters

$cid The cache ID of the data to retrieve.

Return Value

The full path to the cache file.