Memcached
Memcached
Memcached-backed cache backend.
class Memcached extends \Hazaar\Cache\BackendExtends: Hazaar\Cache\Backend
Uses 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 = 2Type: int
config
Typed view of this backend's options.
private Memcached\Options $configType: Hazaar\Cache\Backend\Memcached\Options
memcached
Active Memcached client instance.
private \Memcached $memcachedType: Memcached
Methods
available
Indicates whether the Memcached extension is available.
public available(): boolReturns: bool
init
Initializes Memcached client connection and backend capabilities.
public init(string $namespace): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$namespace | string | active cache namespace |
has
Checks if a key exists in Memcached.
public has(string $key, bool $checkEmpty): boolReturns: bool
Parameters
| 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): mixedReturns: mixed
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | cache key |
set
Stores a value in Memcached.
public set(string $key, mixed $value, int $timeout): boolReturns: bool
Parameters
| 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): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | cache key |
clear
Flushes all values from the Memcached backend.
public clear(): boolReturns: bool
toArray
Returns all known keys from Memcached.
public toArray(): arrayReturns: array
count
Returns an approximate item count from Memcached stats.
public count(): intReturns: int
key
Builds a namespaced Memcached key.
private key(string $key): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | logical cache key |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:16 +0000