Documentation

Horde_Memcache
in package
implements Serializable

This class provides an API or Horde code to interact with a centrally configured memcache installation.

memcached website: http://www.danga.com/memcached/

Tags
author

Jan Schneider jan@horde.org

author

Michael Slusarz slusarz@horde.org

author

Didi Rieder adrieder@sbox.tugraz.at

category

Horde

license

http://www.horde.org/licenses/lgpl21 LGPL 2.1

Interfaces, Classes and Traits

Serializable

Table of Contents

FLAGS_RESERVED  = 16
The number of bits reserved by PHP's memcache layer for internal flag use.
LOCK_SUFFIX  = '_l'
Suffix added to key to create the lock entry.
LOCK_TIMEOUT  = 30
Locking timeout.
MAX_SIZE  = 1000000
The max storage size of the memcache server. This should be slightly smaller than the actual value due to overhead. By default, the max slab size of memcached (as of 1.1.2) is 1 MB.
VERSION  = 1
Serializable version.
$_locks  : array<string|int, mixed>
Locked keys.
$_logger  : Horde_Log_Logger
Logger instance.
$_memcache  : Memcache
Memcache object.
$_noexist  : array<string|int, mixed>
A list of items known not to exist.
$_params  : array<string|int, mixed>
Memcache defaults.
$_servers  : array<string|int, mixed>
The list of active servers.
__construct()  : mixed
Constructor.
_init()  : mixed
Do initialization.
delete()  : bool
Delete a key.
failover()  : mixed
Failover method.
flush()  : mixed
Mark all entries on a memcache installation as expired.
get()  : mixed
Get data associated with a key.
lock()  : mixed
Obtain lock on a key.
replace()  : bool
Replace the value of a key.
serialize()  : string
Serialize.
set()  : bool
Set the value of a key.
shutdown()  : mixed
Shutdown function.
stats()  : array<string|int, mixed>
Get the statistics output from the current memcache pool.
unlock()  : mixed
Release lock on a key.
unserialize()  : mixed
Unserialize.
_getFlags()  : int
Get flags for memcache call.
_getOSKeyArray()  : array<string|int, mixed>
Returns the key listing of all key IDs for an oversized item.
_key()  : string
Obtains the md5 sum for a key.
_lockAdd()  : mixed
Small wrapper around Memcache[d]#add().
_set()  : bool
Set the value of a key.

Constants

FLAGS_RESERVED

The number of bits reserved by PHP's memcache layer for internal flag use.

public mixed FLAGS_RESERVED = 16

LOCK_SUFFIX

Suffix added to key to create the lock entry.

public mixed LOCK_SUFFIX = '_l'

LOCK_TIMEOUT

Locking timeout.

public mixed LOCK_TIMEOUT = 30

MAX_SIZE

The max storage size of the memcache server. This should be slightly smaller than the actual value due to overhead. By default, the max slab size of memcached (as of 1.1.2) is 1 MB.

public mixed MAX_SIZE = 1000000

VERSION

Serializable version.

public mixed VERSION = 1

Properties

$_locks

Locked keys.

protected array<string|int, mixed> $_locks = array()

$_logger

Logger instance.

protected Horde_Log_Logger $_logger

$_memcache

Memcache object.

protected Memcache $_memcache

$_noexist

A list of items known not to exist.

protected array<string|int, mixed> $_noexist = array()

$_params

Memcache defaults.

protected array<string|int, mixed> $_params = array('compression' => alse, 'hostspec' => array('localhost'), 'large_items' => rue, 'persistent' => alse, 'port' => array(11211), 'prefix' => 'horde')

$_servers

The list of active servers.

protected array<string|int, mixed> $_servers = array()

Methods

__construct()

Constructor.

public __construct([array<string|int, mixed> $params = array() ]) : mixed
Parameters
$params : array<string|int, mixed> = 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)
Tags
throws
Horde_Memcache_Exception
Return values
mixed

delete()

Delete a key.

public delete(string $key, int $timeout) : bool
Parameters
$key : string

The key.

$timeout : int

Expiration time in seconds.

Tags
see
Memcache::delete()
Return values
bool

True on success.

failover()

Failover method.

public failover(string $host, int $port) : mixed
Parameters
$host : string

Hostname.

$port : int

Port.

Tags
see
Memcache::addServer()
throws
Horde_Memcache_Exception
Return values
mixed

flush()

Mark all entries on a memcache installation as expired.

public flush() : mixed
Return values
mixed

get()

Get data associated with a key.

public get(mixed $keys) : mixed
Parameters
$keys : mixed

The key or an array of keys.

Tags
see
Memcache::get()
Return values
mixed

The string/array on success (return type is the type of $keys), false on failure.

lock()

Obtain lock on a key.

public lock(string $key) : mixed
Parameters
$key : string

The key to lock.

Return values
mixed

replace()

Replace the value of a key.

public replace(string $key, string $var, mixed $expire) : bool
Parameters
$key : string

The key.

$var : string

The data to store.

$expire : mixed
Tags
see
Memcache::replace()
Return values
bool

True on success, false if key doesn't exist.

serialize()

Serialize.

public serialize() : string
Return values
string

Serialized representation of this object.

set()

Set the value of a key.

public set(string $key, string $var, mixed $expire) : bool
Parameters
$key : string

The key.

$var : string

The data to store.

$expire : mixed
Tags
see
Memcache::set()
Return values
bool

True on success.

shutdown()

Shutdown function.

public shutdown() : mixed
Return values
mixed

stats()

Get the statistics output from the current memcache pool.

public stats() : array<string|int, mixed>
Return values
array<string|int, mixed>

The output from Memcache::getExtendedStats() using the current configuration values.

unlock()

Release lock on a key.

public unlock(string $key) : mixed
Parameters
$key : string

The key to lock.

Return values
mixed

unserialize()

Unserialize.

public unserialize(string $data) : mixed
Parameters
$data : string

Serialized data.

Tags
throws
Exception
throws
Horde_Memcache_Exception
Return values
mixed

_getFlags()

Get flags for memcache call.

protected _getFlags(int $count) : int
Parameters
$count : int
Return values
int

_getOSKeyArray()

Returns the key listing of all key IDs for an oversized item.

protected _getOSKeyArray(mixed $key, mixed $length) : array<string|int, mixed>
Parameters
$key : mixed
$length : mixed
Return values
array<string|int, mixed>

The array of key IDs.

_key()

Obtains the md5 sum for a key.

protected _key(string $key) : string
Parameters
$key : string

The key.

Return values
string

The corresponding memcache key.

_lockAdd()

Small wrapper around Memcache[d]#add().

protected _lockAdd(string $key) : mixed
Parameters
$key : string

The key to lock.

Return values
mixed

_set()

Set the value of a key.

protected _set(string $key, string $var, mixed $expire[, mixed $len = null ]) : bool
Parameters
$key : string

The key.

$var : string

The data to store (serialized).

$expire : mixed
$len : mixed = null
Return values
bool

True on success.

Search results