MemcachedAdapter
extends AbstractAdapter
in package
Tags
Table of Contents
Constants
- DEFAULT_CLIENT_OPTIONS = ['persistent_id' => null, 'username' => null, 'password' => null, \Memcached::OPT_SERIALIZER => \Memcached::SERIALIZER_PHP]
- RESERVED_MEMCACHED = " \n\r\t\v\f\x00"
- 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 = '@()\\{}/'
Properties
- $maxIdLength : mixed
- $apcuSupported : mixed
- $client : mixed
- $lazyClient : mixed
- $marshaller : mixed
- $phpFilesSupported : mixed
Methods
- __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() : bool
- {@inheritdoc}
- doDelete() : bool
- {@inheritdoc}
- doFetch() : iterable<string|int, mixed>
- {@inheritdoc}
- doHave() : bool
- {@inheritdoc}
- doSave() : array<string|int, mixed>|bool
- {@inheritdoc}
- checkResultCode() : mixed
- decodeKey() : string
- encodeKey() : string
- getClient() : Memcached
Constants
DEFAULT_CLIENT_OPTIONS
private
mixed
DEFAULT_CLIENT_OPTIONS
= ['persistent_id' => null, 'username' => null, 'password' => null, \Memcached::OPT_SERIALIZER => \Memcached::SERIALIZER_PHP]
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
= " \n\r\t\v\f\x00"
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 = 0 ][, MarshallerInterface $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 = 0
- $marshaller : MarshallerInterface = null
commit()
{@inheritdoc}
public
commit() : bool
Return values
boolcreateConnection()
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
MemcachedcreateSystemCache()
Returns the best possible adapter that your runtime supports.
public
static createSystemCache(string $namespace, int $defaultLifetime, string $version, string $directory[, LoggerInterface $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
Return values
AdapterInterfaceisSupported()
public
static isSupported() : mixed
doClear()
{@inheritdoc}
protected
doClear(string $namespace) : bool
Parameters
- $namespace : string
Return values
booldoDelete()
{@inheritdoc}
protected
doDelete(array<string|int, mixed> $ids) : bool
Parameters
- $ids : array<string|int, mixed>
Return values
booldoFetch()
{@inheritdoc}
protected
doFetch(array<string|int, mixed> $ids) : iterable<string|int, mixed>
Parameters
- $ids : array<string|int, mixed>
Return values
iterable<string|int, mixed>doHave()
{@inheritdoc}
protected
doHave(string $id) : bool
Parameters
- $id : string
Return values
booldoSave()
{@inheritdoc}
protected
doSave(array<string|int, mixed> $values, int $lifetime) : array<string|int, mixed>|bool
Parameters
- $values : array<string|int, mixed>
- $lifetime : int
Return values
array<string|int, mixed>|boolcheckResultCode()
private
checkResultCode(mixed $result) : mixed
Parameters
- $result : mixed
decodeKey()
private
static decodeKey(string $key) : string
Parameters
- $key : string
Return values
stringencodeKey()
private
static encodeKey(string $key) : string
Parameters
- $key : string
Return values
stringgetClient()
private
getClient() : Memcached