class CRM_Utils_Cache_Memcached implements CRM_Utils_Cache_Interface

Traits

Constants

DEFAULT_HOST

DEFAULT_PORT

DEFAULT_TIMEOUT

DEFAULT_PREFIX

MAX_KEY_LEN

NS_LOCAL_TTL

If another process clears namespace, we'll find out in ~5 sec.

Properties

protected string $_host The host name of the memcached server
protected int $_port The port on which to connect on
protected int $_timeout The default timeout to use
protected string $_prefix The prefix prepended to cache keys.
protected Memcached $_cache The actual memcache object.
protected NULL|array $_truePrefix

Methods

iterable
getMultiple(iterable $keys, mixed $default = NULL)

Obtains multiple cache items by their unique keys.

bool
setMultiple(iterable $values, null|int|DateInterval $ttl = NULL)

Persists a set of key => value pairs in the cache, with an optional TTL.

bool
deleteMultiple(iterable $keys)

Deletes multiple cache items in a single operation.

__construct(array $config)

Constructor.

bool
set(string $key, mixed $value, null|int|DateInterval $ttl = NULL)

No description

mixed
get(string $key, mixed $default = NULL)

No description

bool
has(string $key)

No description

bool
delete(string $key)

No description

mixed|string
cleanKey($key)

No description

bool
flush()

No description

bool
clear()

Delete all values from the cache.

getTruePrefix()

No description

Details

iterable getMultiple(iterable $keys, mixed $default = NULL)

Obtains multiple cache items by their unique keys.

Parameters

iterable $keys A list of keys that can obtained in a single operation.
mixed $default Default value to return for keys that do not exist.

Return Value

iterable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value.

Exceptions

InvalidArgumentException MUST be thrown if $keys is neither an array nor a Traversable, or if any of the $keys are not a legal value.

bool setMultiple(iterable $values, null|int|DateInterval $ttl = NULL)

Persists a set of key => value pairs in the cache, with an optional TTL.

Parameters

iterable $values A list of key => value pairs for a multiple-set operation.
null|int|DateInterval $ttl Optional. The TTL value of this item. If no value is sent and the driver supports TTL then the library may set a default value for it or let the driver take care of that.

Return Value

bool True on success and false on failure.

Exceptions

InvalidArgumentException MUST be thrown if $values is neither an array nor a Traversable, or if any of the $values are not a legal value.

bool deleteMultiple(iterable $keys)

Deletes multiple cache items in a single operation.

Parameters

iterable $keys A list of string-based keys to be deleted.

Return Value

bool True if the items were successfully removed. False if there was an error.

Exceptions

InvalidArgumentException MUST be thrown if $keys is neither an array nor a Traversable, or if any of the $keys are not a legal value.

at line 105
CRM_Utils_Cache_Memcached __construct(array $config)

Constructor.

Parameters

array $config An array of configuration params.

Return Value

CRM_Utils_Cache_Memcached

at line 136
bool set(string $key, mixed $value, null|int|DateInterval $ttl = NULL)

Parameters

string $key
mixed $value
null|int|DateInterval $ttl

Return Value

bool

Exceptions

Exception

at line 164
mixed get(string $key, mixed $default = NULL)

Parameters

string $key
mixed $default

Return Value

mixed The previously set value value, or $default (NULL).

at line 187
bool has(string $key)

Parameters

string $key The cache item key.

Return Value

bool

Exceptions

CacheException

at line 211
bool delete(string $key)

Parameters

string $key

Return Value

bool

at line 226
mixed|string cleanKey($key)

Parameters

$key

Return Value

mixed|string

at line 242
bool flush()

Return Value

bool

at line 251
bool clear()

Delete all values from the cache.

NOTE: flush() and clear() should be aliases. flush() is specified by Civi's traditional interface, and clear() is specified by PSR-16.

Return Value

bool

at line 255
protected getTruePrefix()