PHP Class Habari\Cache

Base abstract class for caching computationally expensive or bandwidth intensive data
Mostra file Open project: habari/system Class Usage Examples

Protected Properties

Property Type Description
$cache_class
$default_group
$instance

Public Methods

Method Description
__static ( ) Set up the static cache instance in __autoload()
debug ( )
expire ( mixed $name, string $match_mode = 'strict' ) Expires the named value from the cache.
expired ( mixed $name ) Check if a named value in the cache has expired.
extend ( mixed $name, integer $expiry ) Extend the expiration of the named cached value.
get ( mixed $name ) : mixed Returns the named value from the cache.
get_class ( ) : string Retrieve the class used for caching
get_group ( $group ) : mixed Returns the group from the cache.
has ( mixed $name ) : boolean Is record with $name in the cache?
has_group ( string $group ) : boolean Is group in the cache?
purge ( ) Empty the cache completely
set ( mixed $name, mixed $value, integer $expiry = 3600, boolean $keep = false ) Set the named value in the cache with an expiration.

Protected Methods

Method Description
_expire ( string $name, $group ) A cache instance implements this to expire the named value from the cache.
_expired ( string $name, $group ) A cache instance implements this to expire the named value from the cache.
_extend ( string $name, integer $expiry, $group ) A cache instance implements this to extend the expiration of the named cached value.
_get ( string $name, $group ) : mixed A cache instance implements this to return the named value from the cache.
_get_group ( $group ) : mixed A cache instance implements this to return the group from the cache.
_has ( string $name, $group ) : boolean A cache instance implements this function to return whether a named cache exists.
_has_group ( $group ) : boolean A cache instance implements this function to return whether a group exists.
_set ( string $name, mixed $value, integer $expiry, $group, $keep ) A cache instance implements this to set the named value in the cache with an expiration.

Private Methods

Method Description
site_unique ( ) : string Return a string unique to this cache so that site caches don't collide

Method Details

__static() public static method

Set up the static cache instance in __autoload()
public static __static ( )

_expire() abstract protected method

A cache instance implements this to expire the named value from the cache.
abstract protected _expire ( string $name, $group )
$name string The name of the cached item

_expired() abstract protected method

A cache instance implements this to expire the named value from the cache.
abstract protected _expired ( string $name, $group )
$name string The name of the cached item

_extend() abstract protected method

A cache instance implements this to extend the expiration of the named cached value.
abstract protected _extend ( string $name, integer $expiry, $group )
$name string The name of the cached item
$expiry integer The duration in seconds to extend the cache expiration by

_get() abstract protected method

A cache instance implements this to return the named value from the cache.
abstract protected _get ( string $name, $group ) : mixed
$name string The name of the cached item
return mixed The item value or null if it doesn't exist in cache

_get_group() abstract protected method

A cache instance implements this to return the group from the cache.
abstract protected _get_group ( $group ) : mixed
return mixed The item value or null if it doesn't exist in cache

_has() abstract protected method

A cache instance implements this function to return whether a named cache exists.
abstract protected _has ( string $name, $group ) : boolean
$name string The name of the cached item
return boolean true if the item is cached, false if not

_has_group() abstract protected method

A cache instance implements this function to return whether a group exists.
abstract protected _has_group ( $group ) : boolean
return boolean true if the group is cached, false if not

_set() abstract protected method

A cache instance implements this to set the named value in the cache with an expiration.
abstract protected _set ( string $name, mixed $value, integer $expiry, $group, $keep )
$name string The name of the cached item
$value mixed The value to store
$expiry integer Number of second after the call that the cache will expire

debug() public static method

public static debug ( )

expire() public static method

Expires the named value from the cache.
public static expire ( mixed $name, string $match_mode = 'strict' )
$name mixed The name of the cached item or an array of array( string $group, string $name )
$match_mode string (optional) how to match item names ('strict', 'regex', 'glob') (default 'strict')

expired() public static method

Check if a named value in the cache has expired.
public static expired ( mixed $name )
$name mixed The name of the cached item or an array of array( string $group, string $name )

extend() public static method

Extend the expiration of the named cached value.
public static extend ( mixed $name, integer $expiry )
$name mixed The name of the cached item or an array of array( string $group, string $name )
$expiry integer The duration in seconds to extend the cache expiration by

get() public static method

Returns the named value from the cache.
public static get ( mixed $name ) : mixed
$name mixed The name of the cached item or an array of array( string $group, string $name )
return mixed The item value or null if it doesn't exist in cache

get_class() public static method

Retrieve the class used for caching
public static get_class ( ) : string
return string The class used for caching

get_group() public static method

Returns the group from the cache.
public static get_group ( $group ) : mixed
return mixed The item value or null if it doesn't exist in cache

has() public static method

Is record with $name in the cache?
public static has ( mixed $name ) : boolean
$name mixed name of the cached item or an array of array( string $group, string $name )
return boolean true if item is cached, false if not

has_group() public static method

Is group in the cache?
public static has_group ( string $group ) : boolean
$group string name of the cached group
return boolean true if group is cached, false if not

purge() public static method

Empty the cache completely
public static purge ( )

set() public static method

Set the named value in the cache with an expiration.
public static set ( mixed $name, mixed $value, integer $expiry = 3600, boolean $keep = false )
$name mixed The name of the cached item or an array of array( string $group, string $name )
$value mixed The value to store
$expiry integer Number of second after the call that the cache will expire
$keep boolean If true, retain the cache value even after expiry but report the cache as expired

Property Details

$cache_class protected_oe static_oe property

protected static $cache_class

$default_group protected_oe static_oe property

protected static $default_group

$instance protected_oe static_oe property

protected static $instance