\Alo\CacheMemcachedWrapper

A wrapper for PHP's Memcached extension. Will try to use the Memcached class first, if it doesn't exist, will use Memcache.

Summary

Methods
Properties
Constants
__construct()
is_available()
purge()
addServer()
getStats()
delete()
get()
getAll()
set()
deleteWithPrefix()
deleteWithSuffix()
getLoadedClass()
No public properties found
CLASS_MEMCACHED
CLASS_MEMCACHE
getAllMemcached()
getAllMemcache()
$mc
$loaded
N/A
No private methods found
No private properties found
N/A

Constants

CLASS_MEMCACHED

CLASS_MEMCACHED

Defines the class as Memcached

CLASS_MEMCACHE

CLASS_MEMCACHE

Defines the class as Memcache

Properties

$mc

$mc : \Memcache|\Memcached

The memcached instance

Type

\Memcache|\Memcached

$loaded

$loaded : boolean

Whether the relevant cache extension is loaded

Type

boolean

Methods

__construct()

__construct(boolean  $initialise_default_server = true) 

Instantiates the class

Parameters

boolean $initialise_default_server

Whether to add a server on construct

is_available()

is_available() : boolean

Checks if a caching extension is available

Returns

boolean

purge()

purge() : boolean

Clears all items from cache

Returns

boolean

addServer()

addServer(string  $ip = ALO_MEMCACHED_IP, string  $port = ALO_MEMCACHED_PORT, integer  $weight = 1) : boolean

Adds a server to the pool

Parameters

string $ip

The server IP

string $port

The server port

integer $weight

The server's weight, ie how likely it is to be used

Returns

boolean

getStats()

getStats() : array

Gets cache process info

Returns

array

delete()

delete(string  $key) : boolean

Deletes a memcache key

Parameters

string $key

The key

Returns

boolean

get()

get(string  $id) : mixed

Gets a cached value

Parameters

string $id

The value's key

Returns

mixed

getAll()

getAll() : array

Return all cached keys and values

Returns

array

set()

set(string  $key, mixed  $var, integer  $expire = 3600) : boolean

Sets a cached key/value pair

Parameters

string $key

The key identifier

mixed $var

The value to set

integer $expire

When to expire the set data. Defaults to 3600s.

Returns

boolean

deleteWithPrefix()

deleteWithPrefix(string  $prefix) : \Alo\Cache\AbstractCache

Deletes all cached entries with the supplied prefix

Parameters

string $prefix

The prefix

Returns

\Alo\Cache\AbstractCache

deleteWithSuffix()

deleteWithSuffix(string  $suffix) : \Alo\Cache\AbstractCache

Deletes all cached entries with the supplied suffix

Parameters

string $suffix

The suffix

Returns

\Alo\Cache\AbstractCache

getLoadedClass()

getLoadedClass() : string|null

Returns the loaded cache class

Returns

string|null

getAllMemcached()

getAllMemcached() : array

The memcached version of getAll()

Returns

array

getAllMemcache()

getAllMemcache() : array

The Memcache version of getAll()

Returns

array