Infinispan Server provides a Memcached endpoint that you can enable alongside the Hot Rod and REST endpoints. This guide provides details about interacting with remote caches with Memcached clients.
The Infinispan server distribution contains a server module that implements the Memcached text and binary protocols. This allows Memcached clients to talk to one or several Infinispan backed Memcached servers. These servers can be standalone just like Memcached, where each server acts independently and does not communicate with the rest. They can also be clustered, where the servers replicate or distribute their contents to other Infinispan backed Memcached servers, providing clients with failover capabilities.
The Memcached text protocol assumes data values read and written by clients are raw bytes. Type negotiation was implemented in the Memcached binary protocol, but no alternative data types have been introduced since.
It’s not possible for a Memcached client to negotiate the data type to obtain data from the server or send data in different formats. The server can optionally be configured to handle values encoded with a certain Media Type. By setting the
client-encoding attribute in the
memcached-connector element, the server will return content in this configured format, and clients can also send data in this format.
client-encoding is useful when a single cache is accessed from multiple remote endpoints (Rest, HotRod, Memcached) and it allows users to tailor the responses/requests to Memcached text clients. For more information on interoperability between endpoints, consult the endpoint interoperability documentation.
The Infinispan Memcached connector supports both manual and automatic protocol configuration by setting the
protocol attribute in the
memcached-connector element to one of
AUTO. Automatic detection depends on whether the Memcached connector is on a dedicated socket binding or is part of a single port endpoint. Detection of text protocol clients in a single port endpoint requires authentication, in order to disambiguate the request from other protocols.
The Infinispan Memcached connector supports authentication for both the text and binary protocols. Because the two variants implement authentication in a different way, the supported mechanisms depend on the protocol in use.
Authentication in the Memcached text protocol is performed by an initial
set command where the key is ignored and the value is a concatenation of the username and the password separated by a space. This authentication scheme requires a security realm which supports plain-text.
Authentication in the Memcached binary protocol is performed via dedicated operations which wrap the SASL challenge/response scheme. This authentication scheme works with all the Infinispan security realm implementations.
Even in a clustered environment, flush_all command leads to the clearing of the Infinispan Memcached server where the call lands. There is no attempt to propagate this flush to other nodes in the cluster. This is done so that the
flush_all with delay use case can be reproduced with the Infinispan Memcached server. The aim of passing a delay to
flush_all is so that different Memcached servers can be flushed at different times, and hence avoid overloading the database with requests as a result of all Memcached servers being empty. For more info, check the Memcached text protocol section on flush_all .
This section details features of the Memcached text protocol that are currently not supported by the Infinispan based Memcached implementation.
There are differences in the nature of the original memcached implementation, which is C/C\\ based, and the Infinispan implementation which is Java based. There are some general purpose statistics that are not supported. For these unsupported stats, Infinispan Memcached server always returns 0.
The statistics setting section of the text protocol has not been implemented due to its volatility.
Since the arguments that can be sent to the Memcached server are not documented, Infinispan Memcached server does not support passing any arguments to the stats command. If any parameters are passed, the Infinispan Memcached server will respond with a
Memcached no longer honors the optional hold time parameter for the delete command. The Infinispan based Memcached server does not implement the feature.
The verbosity command is not supported since Infinispan logging cannot be simplified to defining the logging level alone.