JCache

Extends \JObject

Joomla! Cache base object

This class allows for simple but smart objects with get and set methods and an internal error handler.

package

Joomla.Platform

subpackage

Cache

since

11.1

Methods

__construct

Class constructor, overridden in descendant classes.

__construct(mixed $properties = null) 
inherited
since

11.1

Arguments

$properties

mixedEither and associative array or another object to set the initial properties of the object.

__toString

Magic method to convert the object to a string gracefully.

__toString() : string
inherited deprecated
since

11.1

deprecated

12.3 Classes should provide their own __toString() implementation.

Response

stringThe classname.

_getStorage

Get the cache storage handler

_getStorage() : \JCacheStorage
since

11.1

Response

\JCacheStorageA JCacheStorage object

addIncludePath

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

addIncludePath(string $path = '') : array
static
since

11.1

Arguments

$path

stringA path to search.

Response

arrayAn array with directory elements

clean

Clean cache for a group given a mode.

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

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

since

11.1

Arguments

$group

stringThe cache data group

$mode

stringThe mode for cleaning cache [group|notgroup]

Response

booleanTrue on success, false otherwise

def

Sets a default value if not alreay assigned

def(string $property, mixed $default = null) : mixed
inherited
since

11.1

Arguments

$property

stringThe name of the property.

$default

mixedThe default value.

Response

mixed

gc

Garbage collect expired cache data

gc() : boolean
since

11.1

Response

booleanTrue on success, false otherwise.

get

Returns a property of the object or the default value if the property is not set.

get(string $property, mixed $default = null) : mixed
inherited
since

11.1

see \JObject::getProperties()

Arguments

$property

stringThe name of the property.

$default

mixedThe default value.

Response

mixedThe value of the property.

getAll

Get a list of all cached data

getAll() : mixed
since

11.1

Response

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

getCaching

Get caching state

getCaching() : boolean
since

11.1

Response

booleanCaching state

getError

Get the most recent error message.

getError(integer $i = null, boolean $toString = true) : string
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Arguments

$i

integerOption error index.

$toString

booleanIndicates if JError objects should return their error message.

Response

stringError message

getErrors

Return all errors, if any.

getErrors() : array
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Response

arrayArray of error messages or JErrors.

getInstance

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

getInstance(string $type = 'output', array $options = array()) : \JCache
static
since

11.1

Arguments

$type

stringThe cache object type to instantiate

$options

arrayThe array of options

Response

\JCacheA JCache object

getProperties

Returns an associative array of object properties.

getProperties(boolean $public = true) : array
inherited
since

11.1

see \JObject::get()

Arguments

$public

booleanIf true, returns only the public properties.

Response

array

getStores

Get the storage handlers

getStores() : array
static
since

11.1

Response

arrayAn array of available storage handlers

getWorkarounds

Perform workarounds on retrieved cached data

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

11.1

Arguments

$data

stringCached data

$options

arrayArray of options

Response

stringBody of cached data

lock

Set lock flag on cached item

lock(string $id, string $group = null, string $locktime = null) : object
since

11.1

Arguments

$id

stringThe cache data id

$group

stringThe cache data group

$locktime

stringThe default locktime for locking the cache.

Response

objectProperties are lock and locklooped

makeId

Create safe id for cached data from url parameters set by plugins and framework

makeId() : string
static
since

11.1

Response

stringmd5 encoded cacheid

remove

Remove a cached data entry by id and group

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

11.1

Arguments

$id

stringThe cache data id

$group

stringThe cache data group

Response

booleanTrue on success, false otherwise

set

Modifies a property of the object, creating it if it does not already exist.

set(string $property, mixed $value = null) : mixed
inherited
since

11.1

Arguments

$property

stringThe name of the property.

$value

mixedThe value of the property to set.

Response

mixedPrevious value of the property.

setCaching

Set caching enabled state

setCaching(boolean $enabled) : void
since

11.1

Arguments

$enabled

booleanTrue to enable caching

setError

Add an error message.

setError(string $error) : void
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Arguments

$error

stringError message.

setLifeTime

Set cache lifetime

setLifeTime(integer $lt) : void
since

11.1

Arguments

$lt

integerCache lifetime

setProperties

Set the object properties based on a named array/hash.

setProperties(mixed $properties) : boolean
inherited
since

11.1

see \JObject::set()

Arguments

$properties

mixedEither an associative array or another object.

Response

boolean

setWorkarounds

Create workarounded data to be cached

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

11.1

Arguments

$data

stringCached data

$options

arrayArray of options

Response

stringData to be cached

store

Store the cached data by id and group

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

11.1

Arguments

$data

mixedThe data to store

$id

stringThe cache data id

$group

stringThe cache data group

Response

booleanTrue if cache stored

toString

Converts the object to a string (the class name).

toString() : string
inherited deprecated
since

11.1

deprecated

12.1 Use magic method __toString()

see \JObject::__toString()

Response

string

unlock

Unset lock flag on cached item

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

11.1

Arguments

$id

stringThe cache data id

$group

stringThe cache data group

Response

booleanTrue on success, false otherwise.

Properties

_handler

Storage handler

static
since

11.1

Type(s)

object

_options

Options

since

11.1

Type(s)

array

_errors

An array of error messages or Exception objects.

inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Type(s)

array