MemcachedAdapter
extends AbstractAdapter
in package
Tags
Table of Contents
- RESERVED_MEMCACHED = " "
- We are replacing characters that are illegal in Memcached keys with reserved characters from {@see \Symfony\Contracts\Cache\ItemInterface::RESERVED_CHARACTERS} that are legal in Memcached.
- RESERVED_PSR6 = '@()\{}/'
- $maxIdLength : mixed
- $apcuSupported : mixed
- $client : mixed
- $lazyClient : mixed
- $marshaller : mixed
- $phpFilesSupported : mixed
- __construct() : mixed
- Using a MemcachedAdapter with a TagAwareAdapter for storing tags is discouraged.
- commit() : bool
- {@inheritdoc}
- createConnection() : Memcached
- Creates a Memcached instance.
- createSystemCache() : AdapterInterface
- Returns the best possible adapter that your runtime supports.
- isSupported() : mixed
- doClear() : mixed
- {@inheritdoc}
- doDelete() : mixed
- {@inheritdoc}
- doFetch() : mixed
- {@inheritdoc}
- doHave() : mixed
- {@inheritdoc}
- doSave() : mixed
- {@inheritdoc}
- checkResultCode() : mixed
- decodeKey() : string
- encodeKey() : string
- getClient() : Memcached
Constants
RESERVED_MEMCACHED
We are replacing characters that are illegal in Memcached keys with reserved characters from {@see \Symfony\Contracts\Cache\ItemInterface::RESERVED_CHARACTERS} that are legal in Memcached.
private
mixed
RESERVED_MEMCACHED
= "
"
Note: don’t use AbstractAdapter::NS_SEPARATOR.
RESERVED_PSR6
private
mixed
RESERVED_PSR6
= '@()\{}/'
Properties
$maxIdLength
protected
mixed
$maxIdLength
= 250
$apcuSupported
private
static mixed
$apcuSupported
$client
private
mixed
$client
$lazyClient
private
mixed
$lazyClient
$marshaller
private
mixed
$marshaller
$phpFilesSupported
private
static mixed
$phpFilesSupported
Methods
__construct()
Using a MemcachedAdapter with a TagAwareAdapter for storing tags is discouraged.
public
__construct(Memcached $client[, string $namespace = '' ], int $defaultLifetime[, MarshallerInterface|null $marshaller = null ]) : mixed
Using a RedisAdapter is recommended instead. If you cannot do otherwise, be aware that:
- the Memcached::OPT_BINARY_PROTOCOL must be enabled (that's the default when using MemcachedAdapter::createConnection());
- tags eviction by Memcached's LRU algorithm will break by-tags invalidation; your Memcached memory should be large enough to never trigger LRU.
Using a MemcachedAdapter as a pure items store is fine.
Parameters
- $client : Memcached
- $namespace : string = ''
- $defaultLifetime : int
- $marshaller : MarshallerInterface|null = null
Return values
mixed —commit()
{@inheritdoc}
public
commit() : bool
Return values
bool —createConnection()
Creates a Memcached instance.
public
static createConnection(array<string|int, array<string|int, mixed>>|string|array<string|int, string> $servers[, array<string|int, mixed> $options = [] ]) : Memcached
By default, the binary protocol, no block, and libketama compatible options are enabled.
Examples for servers:
- 'memcached://user:pass@localhost?weight=33'
- [['localhost', 11211, 33]]
Parameters
- $servers : array<string|int, array<string|int, mixed>>|string|array<string|int, string>
-
An array of servers, a DSN, or an array of DSNs
- $options : array<string|int, mixed> = []
Tags
Return values
Memcached —createSystemCache()
Returns the best possible adapter that your runtime supports.
public
static createSystemCache(string $namespace, int $defaultLifetime, string $version, string $directory[, LoggerInterface|null $logger = null ]) : AdapterInterface
Using ApcuAdapter makes system caches compatible with read-only filesystems.
Parameters
- $namespace : string
- $defaultLifetime : int
- $version : string
- $directory : string
- $logger : LoggerInterface|null = null
Return values
AdapterInterface —isSupported()
public
static isSupported() : mixed
Return values
mixed —doClear()
{@inheritdoc}
protected
doClear(string $namespace) : mixed
Parameters
- $namespace : string
Return values
mixed —doDelete()
{@inheritdoc}
protected
doDelete(array<string|int, mixed> $ids) : mixed
Parameters
- $ids : array<string|int, mixed>
Return values
mixed —doFetch()
{@inheritdoc}
protected
doFetch(array<string|int, mixed> $ids) : mixed
Parameters
- $ids : array<string|int, mixed>
Return values
mixed —doHave()
{@inheritdoc}
protected
doHave(string $id) : mixed
Parameters
- $id : string
Return values
mixed —doSave()
{@inheritdoc}
protected
doSave(array<string|int, mixed> $values, int $lifetime) : mixed
Parameters
- $values : array<string|int, mixed>
- $lifetime : int
Return values
mixed —checkResultCode()
private
checkResultCode(mixed $result) : mixed
Parameters
- $result : mixed
Return values
mixed —decodeKey()
private
static decodeKey(string $key) : string
Parameters
- $key : string
Return values
string —encodeKey()
private
static encodeKey(string $key) : string
Parameters
- $key : string
Return values
string —getClient()
private
getClient() : Memcached