Tsugi

MCache
in package

Optional Memcached client for application data.

When ConfigInfo::$memcached is set to a non-empty string (same format as PHP's memcached session save_path, for example host.example.com:11211 or host1:11211,host2:11211) and the memcached PHP extension is available, this class wraps a Memcached instance configured from that string. The client uses the text (non-binary) protocol (Memcached::OPT_BINARY_PROTOCOL is disabled).

If memcached is unset, empty, the extension is missing, or no servers could be added, self::isEnabled() is false and mutating calls are no-ops that return false; self::get() returns false (same as a cache miss).

Table of Contents

Properties

$enabled  : bool
$memcached  : Memcached|null

Methods

__construct()  : mixed
add()  : mixed
delete()  : mixed
get()  : mixed|false
getMemcached()  : Memcached|null
isEnabled()  : mixed
set()  : mixed
addServersFromPath()  : int
Parse a memcached session save_path style server list and add servers.

Properties

$enabled

private bool $enabled = false

$memcached

private Memcached|null $memcached = null

Methods

__construct()

public __construct(object $CFG) : mixed
Parameters
$CFG : object

Typically global $CFG; uses $CFG->memcached when set.

add()

public add(mixed $key, mixed $value[, mixed $expiration = 0 ]) : mixed
Parameters
$key : mixed
$value : mixed
$expiration : mixed = 0

delete()

public delete(mixed $key) : mixed
Parameters
$key : mixed

get()

public get(mixed $key) : mixed|false
Parameters
$key : mixed
Return values
mixed|false —

Value or false if disabled, miss, or error.

getMemcached()

public getMemcached() : Memcached|null
Return values
Memcached|null —

Underlying client when self::isEnabled() is true.

isEnabled()

public isEnabled() : mixed

set()

public set(mixed $key, mixed $value[, mixed $expiration = 0 ]) : mixed
Parameters
$key : mixed
$value : mixed
$expiration : mixed = 0

addServersFromPath()

Parse a memcached session save_path style server list and add servers.

private static addServersFromPath(Memcached $m, string $path) : int
Parameters
$m : Memcached
$path : string

Comma-separated entries; each is host, [ipv6]:port, or host:port (default port 11211).

Return values
int —

Number of servers successfully added.


        
On this page

Search results