\TriTan\CacheCacheMemcache

TriTan CMS \Memcache|\Memcached Class.

Summary

Methods
Properties
Constants
read()
create()
delete()
flush()
flushNamespace()
set()
getStats()
increment()
decrement()
__construct()
update()
addServer()
$connection
$useMemcached
No constants found
uniqueKey()
exists()
_namespace()
$cache
N/A
No private methods found
No private properties found
N/A

Properties

$connection

$connection : \TriTan\Cache\object;

`\Memcache`|`\Memcached` object;

Type

\TriTan\Cache\object;

$useMemcached

$useMemcached : boolean

Type

boolean

$cache

$cache : array

Holds the cached objects.

Type

array

Methods

read()

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

Fetches cached data.

Parameters

integer|string $key

Unique key of the \Memcache|\Memcached item.

string $namespace

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

create()

create(integer|string  $key, mixed  $data, string  $namespace = 'default', integer  $ttl) 

Creates the \Memcache|\Memcached item.

Parameters

integer|string $key

Unique key of the \Memcache|\Memcached item.

mixed $data

Data that should be cached.

string $namespace

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

integer $ttl

Time to live sets the life of the \Memcache|\Memcached item. Default: 0 = will persist until cleared.

delete()

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

Deletes \Memcache|\Memcached based on unique key.

Parameters

integer|string $key

Unique key of \Memcache|\Memcached.

string $namespace

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

flush()

flush() 

Flushes \Memcache|\Memcached completely.

flushNamespace()

flushNamespace(integer|string  $namespace = 'default') 

Removes all cache items from a particular namespace.

Parameters

integer|string $namespace

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

set()

set(integer|string  $key, mixed  $data, string  $namespace = 'default', integer  $ttl) 

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 $ttl

Time to live sets the life of the cache file. Default: 0 = expires immediately after request.

getStats()

getStats() 

Echoes the stats of the cache.

Gives the cache hits, cache misses and cache uptime.

increment()

increment(integer|string  $key, integer  $offset = 1, string  $namespace = 'default') : 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. Default: 'default'.

Returns

false|integer —

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

decrement()

decrement(integer|string  $key, integer  $offset = 1, string  $namespace = 'default') : 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. Default: 'default'.

Returns

false|integer —

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

__construct()

__construct(  $useMemcached) 

Parameters

$useMemcached

update()

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

Updates the \Memcache|\Memcached based on unique key.

Parameters

integer|string $key

Unique key of the \Memcache|\Memcached.

mixed $data

Data that should be cached.

string $namespace

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

integer $ttl

Time to live sets the life of the \Memcache|\Memcached item. Default: 0 = will persist until cleared.

Returns

boolean —

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

addServer()

addServer(array  $servers) 

Add \Memcache|\Memcached servers.

Parameters

array $servers

An array of \Memcache|\Memcached servers.

uniqueKey()

uniqueKey(integer|string  $key, string  $namespace = 'default') 

Generates a unique cache key.

Parameters

integer|string $key

Unique key for cache file.

string $namespace

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

exists()

exists(integer|string  $key, string  $namespace) : boolean

Serves as a utility method to determine whether a key exists in the cache.

Parameters

integer|string $key

Cache key to check for existence.

string $namespace

Cache namespace for the key existence check.

Returns

boolean —

Whether the key exists in the cache for the given namespace.

_namespace()

_namespace(integer|string  $value) 

Unique namespace for cache item.

{@inheritDoc}

Parameters

integer|string $value

The value to slice to get namespace.