class SS_Cache (View source)

The [api:SS_Cache] class provides a bunch of static functions wrapping the Zend_Cache system in something a little more easy to use with the SilverStripe config system.

Properties

protected static array $backends
protected static array $backend_picks
protected static array $cache_lifetime

Methods

protected static 
init()

Initialize the 'default' named cache backend.

public static 
none
add_backend(string $name, string $type, array $options = array())

Add a new named cache backend.

public static 
none
pick_backend(string $name, string $for, int $priority = 1)

Pick a named cache backend for a particular named cache.

public static 
string
get_cache_lifetime(string $for)

Return the cache lifetime for a particular named cache.

public static 
set_cache_lifetime(string $for, int $lifetime = 600, int $priority = 1)

Set the cache lifetime for a particular named cache

public static 
CacheProxy|Zend_Cache_Core
factory(string $for, string $frontend = 'Output', array $frontendOptions = null)

Build a cache object.

Details

static protected init()

Initialize the 'default' named cache backend.

static none add_backend(string $name, string $type, array $options = array())

Add a new named cache backend.

Parameters

string $name

The name of this backend as a freeform string

string $type

The Zend_Cache backend ('File' or 'Sqlite' or ...)

array $options

The Zend_Cache backend options

Return Value

none

See also

http://framework.zend.com/manual/en/zend.cache.html

static none pick_backend(string $name, string $for, int $priority = 1)

Pick a named cache backend for a particular named cache.

The priority call with the highest number will be the actual backend picked. A backend picked for a specific cache name will always be used instead of 'any' if it exists, no matter the priority.

Parameters

string $name

The name of the backend, as passed as the first argument to add_backend

string $for

The name of the cache to pick this backend for (or 'any' for any backend)

int $priority

The priority of this pick

Return Value

none

static string get_cache_lifetime(string $for)

Return the cache lifetime for a particular named cache.

Parameters

string $for

Return Value

string

static set_cache_lifetime(string $for, int $lifetime = 600, int $priority = 1)

Set the cache lifetime for a particular named cache

Parameters

string $for

The name of the cache to set this lifetime for (or 'any' for all backends)

int $lifetime

The lifetime of an item of the cache, in seconds, or -1 to disable caching

int $priority

The priority. The highest priority setting is used. Unlike backends, 'any' is not special in terms of priority.

static CacheProxy|Zend_Cache_Core factory(string $for, string $frontend = 'Output', array $frontendOptions = null)

Build a cache object.

Parameters

string $for

The name of the cache to build

string $frontend

(optional) The type of Zend_Cache frontend

array $frontendOptions

(optional) Any frontend options to use.

Return Value

CacheProxy|Zend_Cache_Core

See also

http://framework.zend.com/manual/en/zend.cache.html