class Cache

Joomla! Cache base object

Properties

static CacheStorage[] $_handler Storage handler
array $_options Cache options

Methods

__construct( array $options)

Constructor

static  CacheController
getInstance( string $type = 'output', array $options = array())

Returns a reference to a cache adapter object, always creating it

static  array
getStores()

Get the storage handlers

void
setCaching( boolean $enabled)

Set caching enabled state

boolean
getCaching()

Get caching state

void
setLifeTime( integer $lt)

Set cache lifetime

boolean
contains( string $id, string $group = null)

Check if the cache contains data stored by ID and group

mixed
get( string $id, string $group = null)

Get cached data by ID and group

mixed
getAll()

Get a list of all cached data

boolean
store( mixed $data, string $id, string $group = null)

Store the cached data by ID and group

boolean
remove( string $id, string $group = null)

Remove a cached data entry by ID and group

boolean
clean( string $group = null, string $mode = 'group')

Clean cache for a group given a mode.

boolean
gc()

Garbage collect expired cache data

lock( string $id, string $group = null, string $locktime = null)

Set lock flag on cached item

boolean
unlock( string $id, string $group = null)

Unset lock flag on cached item

_getStorage()

Get the cache storage handler

static  string
getWorkarounds( string $data, array $options = array())

Perform workarounds on retrieved cached data

static  string
setWorkarounds( string $data, array $options = array())

Create workarounds for data to be cached

static  string
makeId()

Create a safe ID for cached data from URL parameters

static  string
getPlatformPrefix()

Set a prefix cache key if device calls for separate caching

static  array
addIncludePath( array|string $path = '')

Add a directory where Cache should search for handlers. You may either pass a string or an array of directories.

Details

__construct( array $options)

Constructor

Parameters

array $options Cache options

static CacheController getInstance( string $type = 'output', array $options = array())

Returns a reference to a cache adapter object, always creating it

Parameters

string $type The cache object type to instantiate
array $options The array of options

Return Value

CacheController

static array getStores()

Get the storage handlers

Return Value

array

void setCaching( boolean $enabled)

Set caching enabled state

Parameters

boolean $enabled True to enable caching

Return Value

void

boolean getCaching()

Get caching state

Return Value

boolean

void setLifeTime( integer $lt)

Set cache lifetime

Parameters

integer $lt Cache lifetime

Return Value

void

boolean contains( string $id, string $group = null)

Check if the cache contains data stored by ID and group

Parameters

string $id The cache data ID
string $group The cache data group

Return Value

boolean

mixed get( string $id, string $group = null)

Get cached data by ID and group

Parameters

string $id The cache data ID
string $group The cache data group

Return Value

mixed Boolean false on failure or a cached data object

mixed getAll()

Get a list of all cached data

Return Value

mixed Boolean false on failure or an object with a list of cache groups and data

boolean store( mixed $data, string $id, string $group = null)

Store the cached data by ID and group

Parameters

mixed $data The data to store
string $id The cache data ID
string $group The cache data group

Return Value

boolean

boolean remove( string $id, string $group = null)

Remove a cached data entry by ID and group

Parameters

string $id The cache data ID
string $group The cache data group

Return Value

boolean

boolean clean( string $group = null, string $mode = 'group')

Clean cache for a group given a mode.

group mode : cleans all cache in the group notgroup mode : cleans all cache not in the group

Parameters

string $group The cache data group
string $mode The mode for cleaning cache [group|notgroup]

Return Value

boolean True on success, false otherwise

boolean gc()

Garbage collect expired cache data

Return Value

boolean

stdClass lock( string $id, string $group = null, string $locktime = null)

Set lock flag on cached item

Parameters

string $id The cache data ID
string $group The cache data group
string $locktime The default locktime for locking the cache.

Return Value

stdClass Object with properties of lock and locklooped

boolean unlock( string $id, string $group = null)

Unset lock flag on cached item

Parameters

string $id The cache data ID
string $group The cache data group

Return Value

boolean

CacheStorage _getStorage()

Get the cache storage handler

Return Value

CacheStorage

static string getWorkarounds( string $data, array $options = array())

Perform workarounds on retrieved cached data

Parameters

string $data Cached data
array $options Array of options

Return Value

string Body of cached data

static string setWorkarounds( string $data, array $options = array())

Create workarounds for data to be cached

Parameters

string $data Cached data
array $options Array of options

Return Value

string Data to be cached

static string makeId()

Create a safe ID for cached data from URL parameters

Return Value

string MD5 encoded cache ID

static string getPlatformPrefix()

Set a prefix cache key if device calls for separate caching

Return Value

string

static array addIncludePath( array|string $path = '')

Add a directory where Cache should search for handlers. You may either pass a string or an array of directories.

Parameters

array|string $path A path to search.

Return Value

array An array with directory elements