\TriTan\Interfaces\CacheObjectCacheInterface

Summary

Methods
Constants
create()
read()
update()
delete()
flush()
flushNamespace()
set()
increment()
decrement()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

create()

create(integer|string  $key, mixed  $data, string  $namespace = 'default', integer  $expire = 3600) : boolean

Adds data to the cache, if the cache key doesn't already exist.

Parameters

integer|string $key

The cache key to use for retrieval later.

mixed $data

The data to add to the cache.

string $namespace

Optional. Where the cache contents are namespaced.

integer $expire

Optional. When the cache data should expire, in seconds. Default: 3600 seconds = 1 hour / 60 minutes.

Returns

boolean —

False if cache key already exists, true on success.

read()

read(integer|string  $key, string  $namespace = 'default') : boolean|mixed

Retrieves the cache contents from the cache by key and group.

Parameters

integer|string $key

The key under which the cache contents are stored.

string $namespace

Optional. Where the cache contents are namespaced.

Returns

boolean|mixed —

False on failure to retrieve contents or the cache contents on success.

update()

update(integer|string  $key, mixed  $data, string  $namespace = 'default', integer  $expire = 3600) : boolean

Replaces the contents of the cache with new data.

Parameters

integer|string $key

The key for the cache data that should be replaced.

mixed $data

The new data to store in the cache.

string $namespace

Optional. Where the cache contents are namespaced.

integer $expire

Optional. When to expire the cache contents, in seconds. Default: 3600 seconds = 1 hour / 60 minutes.

Returns

boolean —

False if original value does not exist, true if contents were replaced

delete()

delete(integer|string  $key, string  $namespace = 'default') : boolean

Removes the cache contents matching key and group.

Parameters

integer|string $key

What the contents in the cache are called.

string $namespace

Optional. Where the cache contents are namespaced.

Returns

boolean —

True on successful removal, false on failure.

flush()

flush() : boolean

Removes all cache items.

Returns

boolean —

False on failure, true on success

flushNamespace()

flushNamespace(string  $value) : boolean

Removes all cache items from a particular namespace.

Parameters

string $value

The namespace to delete from.

Returns

boolean —

False on failure, true on success

set()

set(integer|string  $key, mixed  $data, string  $namespace = '', integer  $expire = 3600) : boolean

Sets the data contents into the cache.

Parameters

integer|string $key

Unique key of the cache file.

mixed $data

Data that should be cached.

string $namespace

Optional. Where the cache contents are namespaced. Default: 'default'.

integer $expire

Optional. When to expire the cache contents, in seconds. Default: 3600 seconds = 1 hour / 60 minutes.

Returns

boolean —

Returns true if the cache was set and false otherwise.

increment()

increment(integer|string  $key, integer  $offset = 1, string  $namespace = '') : false|integer

Increments numeric cache item's value.

Parameters

integer|string $key

The cache key to increment

integer $offset

Optional. The amount by which to increment the item's value. Default: 1.

string $namespace

Optional. The namespace the key is in.

Returns

false|integer —

False on failure, the item's new value on success.

decrement()

decrement(integer|string  $key, integer  $offset = 1, string  $namespace = '') : false|integer

Decrements numeric cache item's value.

Parameters

integer|string $key

The cache key to decrement.

integer $offset

Optional. The amount by which to decrement the item's value. Default: 1.

string $namespace

Optional. The namespace the key is in.

Returns

false|integer —

False on failure, the item's new value on success.