PHP Class Horde_Memcache, horde

memcached website: http://www.danga.com/memcached/
Author: Jan Schneider ([email protected])
Author: Michael Slusarz ([email protected])
Author: Didi Rieder ([email protected])
Inheritance: implements Serializable
Mostra file Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_locks array Locked keys.
$_logger Horde_Log_Logger Logger instance.
$_memcache Memcache Memcache object.
$_noexist array A list of items known not to exist.
$_params array Memcache defaults.
$_servers array The list of active servers.

Public Methods

Method Description
__construct ( array $params = [] ) Constructor.
_init ( ) Do initialization.
delete ( string $key, integer $timeout ) : boolean Delete a key.
failover ( string $host, integer $port ) Failover method.
flush ( ) Mark all entries on a memcache installation as expired.
get ( mixed $keys ) : mixed Get data associated with a key.
lock ( string $key ) Obtain lock on a key.
replace ( string $key, string $var, $expire ) : boolean Replace the value of a key.
serialize ( ) : string Serialize.
set ( string $key, string $var, $expire ) : boolean Set the value of a key.
shutdown ( ) Shutdown function.
stats ( ) : array Get the statistics output from the current memcache pool.
unlock ( string $key ) Release lock on a key.
unserialize ( string $data ) Unserialize.

Protected Methods

Method Description
_getFlags ( integer $count ) : integer Get flags for memcache call.
_getOSKeyArray ( $key, $length ) : array Returns the key listing of all key IDs for an oversized item.
_key ( string $key ) : string Obtains the md5 sum for a key.
_lockAdd ( string $key ) Small wrapper around Memcache[d]#add().
_set ( string $key, string $var, $expire, $len = null ) : boolean Set the value of a key.

Method Details

__construct() public method

Constructor.
public __construct ( array $params = [] )
$params array Configuration parameters: - compression: (boolean) Compress data inside memcache? DEFAULT: false - c_threshold: (integer) The minimum value length before attempting to compress. DEFAULT: none - hostspec: (array) The memcached host(s) to connect to. DEFAULT: 'localhost' - large_items: (boolean) Allow storing large data items (larger than Horde_Memcache::MAX_SIZE)? Currently not supported with memcached extension. DEFAULT: true - persistent: (boolean) Use persistent DB connections? DEFAULT: false - prefix: (string) The prefix to use for the memcache keys. DEFAULT: 'horde' - port: (array) The port(s) memcache is listening on. Leave empty if using UNIX sockets. DEFAULT: 11211 - weight: (array) The weight(s) to use for each memcached host. DEFAULT: none (equal weight to all servers)

_getFlags() protected method

Get flags for memcache call.
protected _getFlags ( integer $count ) : integer
$count integer
return integer

_getOSKeyArray() protected method

Returns the key listing of all key IDs for an oversized item.
protected _getOSKeyArray ( $key, $length ) : array
return array The array of key IDs.

_init() public method

Do initialization.
public _init ( )

_key() protected method

Obtains the md5 sum for a key.
protected _key ( string $key ) : string
$key string The key.
return string The corresponding memcache key.

_lockAdd() protected method

Small wrapper around Memcache[d]#add().
protected _lockAdd ( string $key )
$key string The key to lock.

_set() protected method

Set the value of a key.
protected _set ( string $key, string $var, $expire, $len = null ) : boolean
$key string The key.
$var string The data to store (serialized).
return boolean True on success.

delete() public method

Delete a key.
See also: Memcache::delete()
public delete ( string $key, integer $timeout ) : boolean
$key string The key.
$timeout integer Expiration time in seconds.
return boolean True on success.

failover() public method

Failover method.
See also: Memcache::addServer()
public failover ( string $host, integer $port )
$host string Hostname.
$port integer Port.

flush() public method

Mark all entries on a memcache installation as expired.
public flush ( )

get() public method

Get data associated with a key.
See also: Memcache::get()
public get ( mixed $keys ) : mixed
$keys mixed The key or an array of keys.
return mixed The string/array on success (return type is the type of $keys), false on failure.

lock() public method

Obtain lock on a key.
public lock ( string $key )
$key string The key to lock.

replace() public method

Replace the value of a key.
See also: Memcache::replace()
public replace ( string $key, string $var, $expire ) : boolean
$key string The key.
$var string The data to store.
return boolean True on success, false if key doesn't exist.

serialize() public method

Serialize.
public serialize ( ) : string
return string Serialized representation of this object.

set() public method

Set the value of a key.
See also: Memcache::set()
public set ( string $key, string $var, $expire ) : boolean
$key string The key.
$var string The data to store.
return boolean True on success.

shutdown() public method

Shutdown function.
public shutdown ( )

stats() public method

Get the statistics output from the current memcache pool.
public stats ( ) : array
return array The output from Memcache::getExtendedStats() using the current configuration values.

unlock() public method

Release lock on a key.
public unlock ( string $key )
$key string The key to lock.

unserialize() public method

Unserialize.
public unserialize ( string $data )
$data string Serialized data.

Property Details

$_locks protected_oe property

Locked keys.
protected array $_locks
return array

$_logger protected_oe property

Logger instance.
protected Horde_Log_Logger $_logger
return Horde_Log_Logger

$_memcache protected_oe property

Memcache object.
protected Memcache $_memcache
return Memcache

$_noexist protected_oe property

A list of items known not to exist.
protected array $_noexist
return array

$_params protected_oe property

Memcache defaults.
protected array $_params
return array

$_servers protected_oe property

The list of active servers.
protected array $_servers
return array