MemcachedBackend
in package
implements
ICacheBackend
Information about the memcached backend.
Table of Contents
Interfaces
- ICacheBackend
- Information about a cache provider. Should not have any external dependencies.
Methods
- createProvider() : MemcachedProvider
- Creates a memcached cache provider.
- isAvailable() : bool
- Checks whether the driver is available and a provider can be made.
- parseDsn() : MemcachedProviderInfo
- Constructs a cache info instance from a dsn.
Methods
createProvider()
Creates a memcached cache provider.
public
createProvider(MemcachedProviderInfo $providerInfo) : MemcachedProvider
Has compatibility with both the newer memcached extension and the older memcache extension. memcached is attempted first.
Parameters
- $providerInfo : MemcachedProviderInfo
-
Memcached provider info.
Return values
MemcachedProvider —Memcached provider instance.
isAvailable()
Checks whether the driver is available and a provider can be made.
public
isAvailable() : bool
Return values
bool —If true a provider can be made, if false a required extension is missing.
parseDsn()
Constructs a cache info instance from a dsn.
public
parseDsn(string|array<string, string|int> $dsn) : MemcachedProviderInfo
Memcached does not support a username or password.
The host part of the URL can be any DNS name, or special values :unix:
and :pool:
, documented further down.
The path part of the URL is used as a key prefix. Any prefix slashes (/
) are trimmed and others are converted to a colon (:
).
Meaning /prefix/test/
is converted to prefix:test:
.
In order to use a Unix socket path, set the host part to :unix:
and specify server=/path/to/socket.sock
in the query.
In order to use a pool of connections, set the host part to :pool:
and specify any amount of params server[]
in the query.
Weights can be specified at the end, prefixed by a semicolon (;
)
Examples include:
-
server[]=/var/run/memcached.sock;20
-
server[]=127.0.0.1;10
-
server[]=[::1]:9001;5
-
server[]=localhost
Internally :unix:
and :pool:
invoke the same behaviour, but please use them appropriately.
Other query fields include:
-
persist=<name>
: a named persistent connection. Named only applied to the memcached implementation, the legacy memcache implementation treats this as a boolean flag. -
proto=ascii
: Forces the memcached implemenation to use the ASCII protocol over the binary one. The legacy memcache implementation always uses the ASCII protocol. -
compress=<no,off,false,0>
: Turns compression of strings larger than 100 characters off. -
nodelay=<no,off,false,0>
: Turns TCP No Delay off. Has no effect on the legacy memcache implementation.
Why is the legacy memcache extension supported? cuz I felt like it.
Parameters
- $dsn : string|array<string, string|int>
-
DSN with provider information.
Return values
MemcachedProviderInfo —Memcached provider info instance.