MemcachedAdapter
class MemcachedAdapter extends AbstractAdapter
Traits
Properties
protected | $maxIdLength |
Methods
Persists several cache items immediately.
Like the native unserialize() function but throws an exception if anything goes wrong.
{@inheritdoc}
Wraps the callback passed to ->get() in a callable.
Using a MemcachedAdapter with a TagAwareAdapter for storing tags is discouraged.
Returns an ApcuAdapter if supported, a PhpFilesAdapter otherwise.
Creates a Memcached instance.
Details
abstract protected array|bool
doSave(array $values, int $lifetime)
Persists several cache items immediately.
bool
enableVersioning(bool $enable = true)
Enables/disables versioning of items.
When versioning is enabled, clearing the cache is atomic and doesn't require listing existing keys to proceed, but old keys may need garbage collection and extra round-trips to the back-end are required.
Calling this method also clears the memoized namespace version and thus forces a resynchonization of it.
static protected mixed
unserialize(string $value)
deprecated
deprecated since Symfony 4.2, use DefaultMarshaller instead.
Like the native unserialize() function but throws an exception if anything goes wrong.
callable
setCallbackWrapper(callable|null $callbackWrapper)
Wraps the callback passed to ->get() in a callable.
__construct(Memcached $client, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface $marshaller = null)
Using a MemcachedAdapter with a TagAwareAdapter for storing tags is discouraged.
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.
static AdapterInterface
createSystemCache(string $namespace, int $defaultLifetime, string $version, string $directory, LoggerInterface $logger = null)
Returns an ApcuAdapter if supported, a PhpFilesAdapter otherwise.
Using ApcuAdapter makes system caches compatible with read-only filesystems.
static Memcached
createConnection(array[]|string|string[] $servers, array $options = array())
Creates a Memcached instance.
By default, the binary protocol, no block, and libketama compatible options are enabled.
Examples for servers: - 'memcached://user:pass@localhost?weight=33' - array(array('localhost', 11211, 33))