JCache
Extends \JObjectJoomla! 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)
since |
11.1 |
---|
Arguments
- $properties
mixed
Either 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
since |
11.1 |
---|---|
deprecated |
12.3 Classes should provide their own __toString() implementation. |
Response
string
The classname.
_getStorage
Get the cache storage handler
_getStorage() : \JCacheStorage
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
since |
11.1 |
---|
Arguments
- $path
string
A path to search.
Response
array
An 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
string
The cache data group- $mode
string
The mode for cleaning cache [group|notgroup]
Response
boolean
True on success, false otherwise
def
Sets a default value if not alreay assigned
def(string $property, mixed $default = null) : mixed
since |
11.1 |
---|
Arguments
- $property
string
The name of the property.- $default
mixed
The default value.
Response
mixed
gc
Garbage collect expired cache data
gc() : boolean
since |
11.1 |
---|
Response
boolean
True 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
since |
11.1 |
---|---|
see | \JObject::getProperties() |
Arguments
- $property
string
The name of the property.- $default
mixed
The default value.
Response
mixed
The value of the property.
getAll
Get a list of all cached data
getAll() : mixed
since |
11.1 |
---|
Response
mixed
Boolean false on failure or an object with a list of cache groups and data
getCaching
Get caching state
getCaching() : boolean
since |
11.1 |
---|
Response
boolean
Caching state
getError
Get the most recent error message.
getError(integer $i = null, boolean $toString = true) : string
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Arguments
- $i
integer
Option error index.- $toString
boolean
Indicates if JError objects should return their error message.
Response
string
Error message
getErrors
Return all errors, if any.
getErrors() : array
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Response
array
Array 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
since |
11.1 |
---|
Arguments
- $type
string
The cache object type to instantiate- $options
array
The array of options
Response
\JCache
A JCache object
getProperties
Returns an associative array of object properties.
getProperties(boolean $public = true) : array
since |
11.1 |
---|---|
see | \JObject::get() |
Arguments
- $public
boolean
If true, returns only the public properties.
Response
array
getStores
Get the storage handlers
getStores() : array
since |
11.1 |
---|
Response
array
An array of available storage handlers
getWorkarounds
Perform workarounds on retrieved cached data
getWorkarounds(string $data, array $options = array()) : string
since |
11.1 |
---|
Arguments
- $data
string
Cached data- $options
array
Array of options
Response
string
Body 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
string
The cache data id- $group
string
The cache data group- $locktime
string
The default locktime for locking the cache.
Response
object
Properties are lock and locklooped
makeId
Create safe id for cached data from url parameters set by plugins and framework
makeId() : string
since |
11.1 |
---|
Response
string
md5 encoded cacheid
remove
Remove a cached data entry by id and group
remove(string $id, string $group = null) : boolean
since |
11.1 |
---|
Arguments
- $id
string
The cache data id- $group
string
The cache data group
Response
boolean
True 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
since |
11.1 |
---|
Arguments
- $property
string
The name of the property.- $value
mixed
The value of the property to set.
Response
mixed
Previous value of the property.
setCaching
Set caching enabled state
setCaching(boolean $enabled) : void
since |
11.1 |
---|
Arguments
- $enabled
boolean
True to enable caching
setError
Add an error message.
setError(string $error) : void
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Arguments
- $error
string
Error message.
setLifeTime
Set cache lifetime
setLifeTime(integer $lt) : void
since |
11.1 |
---|
Arguments
- $lt
integer
Cache lifetime
setProperties
Set the object properties based on a named array/hash.
setProperties(mixed $properties) : boolean
since |
11.1 |
---|---|
see | \JObject::set() |
Arguments
- $properties
mixed
Either an associative array or another object.
Response
boolean
setWorkarounds
Create workarounded data to be cached
setWorkarounds(string $data, array $options = array()) : string
since |
11.1 |
---|
Arguments
- $data
string
Cached data- $options
array
Array of options
Response
string
Data 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
mixed
The data to store- $id
string
The cache data id- $group
string
The cache data group
Response
boolean
True if cache stored
toString
Converts the object to a string (the class name).
toString() : string
unlock
Unset lock flag on cached item
unlock(string $id, string $group = null) : boolean
since |
11.1 |
---|
Arguments
- $id
string
The cache data id- $group
string
The cache data group
Response
boolean
True on success, false otherwise.
Properties
_handler
Storage handler
since |
11.1 |
---|
Type(s)
object
_options
Options
since |
11.1 |
---|
Type(s)
array
_errors
An array of error messages or Exception objects.