Memcached
Memcached
Memcached-backed cache backend.
class Memcached extends \Hazaar\Cache\Backend\BackendUses the PHP memcached extension for fast, networked key/value caching with optional multi-server distribution. Keys are namespaced to isolate cache contexts.
Supported configuration options include server list, port, persistent client identifier, and transport compression.
Properties
weight
Backend priority weight used in backend chain selection.
protected int $weight = 2public $Methods
available
Indicates whether the Memcached extension is available.
public available(): boolinit
Initializes Memcached client connection and backend capabilities.
public init(string $namespace): voidParameters
| Parameter | Type | Description |
|---|---|---|
$namespace | string | active cache namespace |
has
Checks if a key exists in Memcached.
public has(string $key, bool $checkEmpty): boolParameters
| Parameter | Type | Description |
|---|---|---|
$key | string | cache key |
$checkEmpty | bool | present for interface compatibility; not used |
get
Retrieves a value from Memcached.
public get(string $key): mixedParameters
| Parameter | Type | Description |
|---|---|---|
$key | string | cache key |
set
Stores a value in Memcached.
public set(string $key, mixed $value, int $timeout): boolParameters
| Parameter | Type | Description |
|---|---|---|
$key | string | cache key |
$value | mixed | value to store |
$timeout | int | TTL in seconds |
remove
Removes a key from Memcached.
public remove(string $key): boolParameters
| Parameter | Type | Description |
|---|---|---|
$key | string | cache key |
clear
Flushes all values from the Memcached backend.
public clear(): booltoArray
Returns all known keys from Memcached.
public toArray(): voidcount
Returns an approximate item count from Memcached stats.
public count(): intkey
Builds a namespaced Memcached key.
private key(string $key): stringParameters
| Parameter | Type | Description |
|---|---|---|
$key | string | logical cache key |
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:25 +0000