class Cache extends Object implements ArrayAccess

Implements the cache for a application.

Constants

PRIORITY

dependency

EXPIRATION

dependency

EXPIRE

dependency

SLIDING

dependency

TAGS

dependency

FILES

dependency

ITEMS

dependency

CONSTS

dependency

CALLBACKS

dependency

ALL

dependency

internal NAMESPACE_SEPARATOR

Methods

__construct(IStorage $storage, $namespace = NULL)

No description

getStorage()

Returns cache storage.

string
getNamespace()

Returns cache namespace.

derive($namespace)

Returns new nested cache object.

mixed|null
load($key, $fallback = NULL)

Reads the specified item from the cache or generate it.

mixed
save($key, $data, array $dependencies = NULL)

Writes item into the cache.

void
remove($key)

Removes item from the cache.

void
clean(array $conditions = NULL)

Removes items from the cache by conditions.

mixed
call($function)

Caches results of function/method calls.

wrap($function, array $dependencies = NULL)

Caches results of function/method calls.

start($key)

Starts the output cache.

string
generateKey($key)

Generates internal cache key.

offsetSet($key, $data) deprecated

No description

offsetGet($key) deprecated

No description

offsetExists($key) deprecated

No description

offsetUnset($key) deprecated

No description

release() deprecated

No description

static bool
checkCallbacks($callbacks)

Checks CALLBACKS dependencies.

Details

at line 47
__construct(IStorage $storage, $namespace = NULL)

No description

Parameters

IStorage $storage
$namespace

at line 58
IStorage getStorage()

Returns cache storage.

Return Value

IStorage

at line 68
string getNamespace()

Returns cache namespace.

Return Value

string

at line 79
Cache derive($namespace)

Returns new nested cache object.

Parameters

$namespace

Return Value

Cache

at line 92
mixed|null load($key, $fallback = NULL)

Reads the specified item from the cache or generate it.

Parameters

$key
$fallback

Return Value

mixed|null

at line 121
mixed save($key, $data, array $dependencies = NULL)

Writes item into the cache.

Dependencies are:

  • Cache::PRIORITY => (int) priority
  • Cache::EXPIRATION => (timestamp) expiration
  • Cache::SLIDING => (bool) use sliding expiration?
  • Cache::TAGS => (array) tags
  • Cache::FILES => (array|string) file names
  • Cache::ITEMS => (array|string) cache items
  • Cache::CONSTS => (array|string) cache items

Parameters

$key
$data
array $dependencies

Return Value

mixed

value itself

Exceptions

InvalidArgumentException

at line 188
void remove($key)

Removes item from the cache.

Parameters

$key

Return Value

void

at line 202
void clean(array $conditions = NULL)

Removes items from the cache by conditions.

Conditions are:

  • Cache::PRIORITY => (int) priority
  • Cache::TAGS => (array) tags
  • Cache::ALL => TRUE

Parameters

array $conditions

Return Value

void

at line 214
mixed call($function)

Caches results of function/method calls.

Parameters

$function

Return Value

mixed

at line 232
Closure wrap($function, array $dependencies = NULL)

Caches results of function/method calls.

Parameters

$function
array $dependencies

Return Value

Closure

at line 254
OutputHelper|null start($key)

Starts the output cache.

Parameters

$key

Return Value

OutputHelper|null

at line 270
protected string generateKey($key)

Generates internal cache key.

Parameters

$key

Return Value

string

at line 282
offsetSet($key, $data) deprecated

deprecated

No description

Parameters

$key
$data

at line 292
offsetGet($key) deprecated

deprecated

No description

Parameters

$key

at line 307
offsetExists($key) deprecated

deprecated

No description

Parameters

$key

at line 318
offsetUnset($key) deprecated

deprecated

No description

Parameters

$key

at line 328
release() deprecated

deprecated

No description

at line 343
static bool checkCallbacks($callbacks)

Checks CALLBACKS dependencies.

Parameters

$callbacks

Return Value

bool