Updated on 2022-08-06 GMT+08:00

Memcached Commands

Memcached supports the TCP-based text protocol and binary protocol. Any clients compatible with a Memcached protocol can access DCS instances.

Memcached Text Protocol

The Memcached text protocol uses ASCII text to transfer commands, which helps you compile clients and debug problems. DCS Memcached instances can even be directly connected using Telnet.

Compared with the Memcached binary protocol, the Memcached text protocol is compatible with more open-source clients, but the text protocol does not support authentication.

Clients can use the Memcached text protocol to access DCS Memcached instances only if password-free access is enabled. Password-free access means that access to DCS Memcached instances will not be username- and password-protected, and any Memcached clients that satisfy security group rules in the same VPC can access the instances. Enabling password-free access poses security risks. Exercise caution when enabling password-free access.

Table 1 lists the commands supported by the Memcached text protocol and describes whether these commands are supported by DCS Memcached instances.

Table 1 Commands supported by the Memcached text protocol

Command

Function

Supported by DCS

add

Adding data

Yes

set

Sets data, including adding or modifying data.

Yes

replace

Replaces data.

Yes

append

Adds data after the value of the specified key.

Yes

prepend

Adds data before the value of a specified key.

Yes

cas

Checks and set data.

Yes

get

Queries data.

Yes

gets

Queries data details.

Yes

delete

Deletes data.

Yes

incr

Adds the specified amount to the requested counter.

Yes

decr

Removes the specified amount to the requested counter.

Yes

touch

Updates the expiration time of existing data.

Yes

quit

Closes the connection.

Yes

flush_all

Clearing DCS instance data

NOTE:

The value of the delay option (if any) must be 0.

Yes

version

Queries Memcached version information.

Yes

stats

Manages operation statistics.

NOTE:

Currently, only basic statistics can be queried. Commands on optional parameters cannot be queried.

Yes

cache_memlimit

Adjusts the cache memory limit.

No

slabs

Queries usage of internal storage structures.

No

lru

Manages policies of deleting expired data.

No

lru_crawler

Manages threads of deleting expired data.

No

verbosity

Sets the verbosity level of the logging output.

No

watch

Inspects what's going on internally.

No

Memcached Binary Protocol

The Memcached binary protocol encodes commands and operations into specific structures before sending them. Commands are represented by predefined character strings.

The Memcached binary protocol provides more features but fewer clients than the Memcached text protocol. The Memcached binary protocol is more secure than the Memcached text protocol as it additionally supports simple authentication and security layer (SASL) authentication.

Table 2 lists the commands supported by the Memcached binary protocol and describes whether these commands are supported by DCS Memcached instances.

Table 2 Commands supported by the Memcached binary protocol

Command Code

Command

Function

Supported by DCS

0x00

GET

Queries data.

Yes

0x01

SET

Sets data, including adding or modifying data.

Yes

0x02

ADD

Adding data

Yes

0x03

REPLACE

Replaces data.

Yes

0x04

DELETE

Deletes data.

Yes

0x05

INCREMENT

Adds the specified amount to the requested counter.

Yes

0x06

DECREMENT

Removes the specified amount to the requested counter.

Yes

0x07

QUIT

Closes the connection.

Yes

0x08

FLUSH

Clearing DCS instance data

NOTE:

The value of the delay option (if any) must be 0.

Yes

0x09

GETQ

Queries data. The client will not receive any response in case of failure.

Yes

0x0a

NOOP

No-operation instruction, equivalent to ping.

Yes

0x0b

VERSION

Queries Memcached version information.

Yes

0x0c

GETK

Queries data and adds a key into the response packet.

Yes

0x0d

GETKQ

Queries data and returns a key. The client will not receive any response in case of failure.

Yes

0x0e

APPEND

Adds data after the value of the specified key.

Yes

0x0f

PREPEND

Adds data before the value of a specified key.

Yes

0x10

STAT

Queries statistics of DCS Memcached instances.

NOTE:

Currently, only basic statistics can be queried. Commands on optional parameters cannot be queried.

Yes

0x11

SETQ

Sets data, including adding or modifying data.

The SETQ command only returns a response on failures. The client will not receive any response in the case of success.

Yes

0x12

ADDQ

Adds data. The client will not receive any response in the case of success.

Yes

0x13

REPLACEQ

Replaces data. The client will not receive any response in the case of success.

Yes

0x14

DELETEQ

Deletes data. The client will not receive any response in the case of success.

Yes

0x15

INCREMENTQ

Adds the specified amount to the requested counter. The client will not receive any response in the case of success.

Yes

0x16

DECREMENTQ

Removes the specified amount to the requested counter. The client will not receive any response in the case of success.

Yes

0x17

QUITQ

Closes the connection.

Yes

0x18

FLUSHQ

Clears data and returns no information.

NOTE:

The value of the delay option (if any) must be 0.

Yes

0x19

APPENDQ

Adds data after the value of the specified key. The client will not receive any response in the case of success.

Yes

0x1a

PREPENDQ

Adds data before the value of a specified key. The client will not receive any response in the case of success.

Yes

0x1c

TOUCH

Updates the expiration time of existing data.

Yes

0x1d

GAT

Queries data and updates the expiration time of existing data.

Yes

0x1e

GATQ

Queries data and returns a key. The client will not receive any response in case of failure.

Yes

0x23

GATK

Queries data, adds a key into the response packet, and updates the expiration time of existing data.

Yes

0x24

GATKQ

Queries data, returns a key, and updates the expiration time of existing data. The client will not receive any response in case of failure.

Yes

0x20

SASL_LIST_MECHS

Asks the server what SASL authentication mechanisms it supports.

Yes

0x21

SASL_AUTH

Starts SASL authentication.

Yes

0x22

SASL_STEP

Further authentication steps are required.

Yes