Help Center > > Service Overview> Command Compatibility> Redis Command Compatibility

Redis Command Compatibility

Updated at: Sep 11, 2019 GMT+08:00

This section describes DCS's compatibility with Redis commands, including supported commands, disabled commands, unsupported scripts and commands of later Redis versions, and restrictions on command usage.

For more information about the command syntax, visit the Redis official website.

DCS for Redis instances support most Redis commands. Any client compatible with the Redis protocol can access DCS.

  • For security purposes, some Redis commands are disabled in DCS. For details, see Disabled Redis Commands.
  • Some Redis commands have usage restrictions, which are described in Other Command Usage Restrictions.
  • Some Redis commands are supported by cluster DCS instances for multi-key operations in the same slot. For details, see Table 6.

Commands Supported by DCS for Redis 3.0

The following lists commands supported by DCS for Redis 3.0.

NOTE:

Commands added in later Redis versions are not supported by earlier versions. Run a command on redis-cli to check whether it is supported by DCS for Redis. If the message "(error) ERR unknown command" is returned, the command is not supported.

Table 1 Commands supported by DCS for Redis 3.0

Category

Command

Key

DEL, DUMP, EXISTS, EXPIRE, MOVE, PERSISI, PTTL, RANDOMKEY, RENAME, RENAMENX, RESTORE, SORT, TTL, TYPE, SCAN, OBJIECT

String

APPEND, BITCOUNT, BITOP, BITPOS, DECR, DECRBY, GET, GETRANGE, GETSET, INCR, INCRBY, INCRBYFLOAT, MGET, MSET, MSETNX, PSETEX, SET, SETBIT, SETEX, SETNX, SETRANGE, STRLEN

Hash

HDEL, HEXISTS, HGET, HGETALL, HINCRBY, HINCRBYFLOAT, HKEYS, HMGET, HMSET, HSET, HSETNX, HVALS, HSCAN

List

BLPOP, BRPOP, BRPOPLRUSH, LINDEX, LINSERT, LLEN, LPOP, LPUSHX, LRANGE, LREM, LSET, LTRIM, RPOP, RPOPLPU, RPOPLPUSH, RPUSH, RPUSHX

SPOP (Supported by DCS Redis 4.0 and 5.0)

Set

SADD, SCARD, SDIFF, SDIFFSTORE, SINTER, SINTERSTORE, SISMEMBER, SMEMBERS, SMOVE, SPOP, SRANDMEMBER, SREM, SUNION, SUNIONSTORE, SSCAN

Sorted set

ZADD, ZCARD, ZCOUNT, ZINCRBY, ZRANGE, ZRANGEBYSCORE, ZRANK, ZREMRANGEBYRANK, ZREMRANGEBYCORE, ZREVRANGE, ZREVRANGEBYSCORE, ZREVRANK, ZSCORE, ZUNIONSTORE, ZINTERSTORE, ZSCAN, ZRANGEBYLEX

HyperLogLog

PFADD, PFCOUNT, PFMERGE

Pub/Sub

PSUBSCRIBE, PUBLISH, PUBSUB, PUNSUBSCRIBE, SUBSCRIBE, UNSUBSCRIBE

Transaction

DISCARD, EXEC, MULTI, UNWATCH, WATCH

Connection

AUTH, ECHO, PING, QUIT, SELECT

Server

FLUSHALL, FLUSHDB, DBSIZE, TIME, INFO, KEYS, CLIENT KILL, CLIENT LIST, CLIENT GETNAME, CLIENT SETNAME, CONFIG GET, MONITOR, SLOWLOG, ROLE

Scripting

EVAL, EVALSHA, SCRIPT EXISTS, SCRIPT FLUSH, SCRIPT KILL, SCRIPT LOAD

Geo

GEOADD, GEOHASH, GEOPOS, GEODIST, GEORADIUS, GEORADIUSBYMEMBER

New Commands Supported by DCS for Redis 4.0

In addition to all the commands supported in DCS Redis 3.0, DCS Redis 4.0 added support for the following commands:

Table 2 New commands and scripts supported by DCS Redis 4.0

Category

Command/Script

Description

List

SPOP

Removes and returns one or more random elements. Available since Redis 3.2.

HSTRLEN

Returns the string length of the value associated with field in the hash stored at key. Available since Redis 3.2.

BITFIELD

Treats a Redis string as an array of bits. Available since Redis 3.2.

ZLEXCOUNT

Returns the number of elements in the sorted set.

SWAPDB

Swaps two Redis databases. Available since Redis 4.0.

MEMORY

Queries and manages memory usage, such as querying memory usage of a key, querying overall memory usage, applying for releasing memory, and querying the internal status of a memory allocator. Available since Redis 4.0.

NOTE:

For details about new commands supported by DCS for Redis 4.0, see New Features of DCS for Redis 4.0.

New Commands Supported by DCS for Redis 5.0

In addition to all the commands supported in DCS Redis 3.0 and 4.0, DCS Redis 5.0 added support for the following commands:

Table 3 New commands and scripts supported by DCS Redis 5.0

Command/Script

Description

Stream commands

XACK, XADD, XCLAIM, XDEL, XGROUP, XINFO, XLEN, XPENDING, XRANGE, XREAD, XREADGROUP, XREVRANGE, XTRIM

For details about the description and syntax, see Table 2.

ZPOPMIN

Removes and returns multiple members with the lowest scores in the sorted set.

ZPOPMAX

Removes and returns multiple members with the highest scores in the sorted set.

Disabled Redis Commands

Redis APIs of single-node and master/standby DCS instances are compatible with open-source Redis for data access. For ease of use and security purposes, some management operations cannot be initiated from a Redis client. Related commands are listed in Table 4.

Table 4 Redis commands disabled in single-node and master/standby DCS instances

Command

Description

Key

MIGRATE

Transfers a key from one Redis instance to another.

Server

SLAVEOF

Changes the replication settings of a replica on the fly.

SHUTDOWN

Stops all the clients and quits the Redis process.

LASTSAVE

Returns the time of the last data persistence to disk executed with success.

DEBUG SEGFAULT

This is a debugging command that should not be used by clients.

DEBUG OBJECT

This is a debugging command that should not be used by clients.

CONFIG SET

Reconfigures the server at run time without the need to restart Redis.

CONFIG REWRITE

Rewrites the redis.conf file the server was started with.

CONFIG RESETSTAT

Resets the statistics reported using the INFO command.

COMMAND

Returns array reply of details about all Redis commands.

COMMAND INFO

Returns array reply of details about multiple Redis commands.

COMMAND GETKEYS

Returns array reply of keys of a full Redis command.

COMMAND COUNT

Returns integer reply of the number of total commands in the Redis server.

SAVE

Performs a synchronous save on disk, producing a point in time snapshot of all the data inside the Redis instance, in the form of an RDB file.

BGSAVE

Asynchronously saves the database on disk.

BGREWRITEAOF

Starts an Append Only File (AOF) rewrite process.

In additional to these commands, cluster DCS instances do not support the commands listed in Table 5.

Table 5 Redis commands disabled in cluster DCS instances.

Command

Description

Server

SYNC

An internal command used for full replication.

PSYNC

An internal command used for partial replication.

Scripting

SCRIPT DEBUG

Sets the debug mode for scripts.

Transaction

DISCARD

Flushes all previously queued commands in a transaction.

EXEC

Executes all previously queued commands in a transaction.

MULTI

Marks the start of a transaction block.

UNWATCH

Flushes all the previously watched keys for a transaction.

WATCH

Marks the given key or keys to be watched. If the key or keys are modified by other commands before WATCH is executed, the transaction is interrupted.

Connection

SELECT

Selects the Redis logical database having the specified zero-based numeric index.

Key

MOVE

Moves key of the currently selected database to the specified destination database.

Cluster

CLUSTER

Used for cluster management.

codis (Proxy Cluster)

TIME

Returns the current server time.

SLOTSINFO

Returns the number of slots and the size of each slot in Redis.

SLOTSDEL

Deletes all key-value pairs in multiple slots in Redis.

SLOTSMGRTSLOT

Randomly migrates a key-value pair in a slot to the destination.

SLOTSMGRTONE

Migrates a specified key-value pair to the destination.

SLOTSCHECK

Checks whether slots meet the following consistency requirements:

  • All the keys in the slots have a corresponding value in the database.
  • All the keys in the database have a value in the corresponding slot.

SLOTSMGRTTAGSLOT

Migrates all key-value pairs with the same tag as a randomly selected key in a slot.

SLOTSMGRTTAGONE

Migrates all key-value pairs with the same tag as a specified key.

List

NOTE:

The following commands are supported by some instances of older versions, but avoid using these commands because they might block Redis.

BLPOP

The blocking version of LPOP because it blocks the connection when there are no elements to pop from any of the given lists until the specified timeout has expired or a non-empty element is popped.

BRPOP

The blocking version of RPOP because it blocks the connection when there are no elements to pop from any of the given lists until the specified timeout has expired or a non-empty element is popped.

After the disabled commands are run on redis-cli, the message "(error) ERR unknown command 'xxx'" is returned in most cases. However, after the MONITOR command is run, redis-cli waits for the monitoring result. This is a behavior found not just in redis-cli, but in other Redis clients as well. DCS cannot control their behavior.

Restricted Redis Commands

Some Redis commands are supported by cluster DCS instances for multi-key operations in the same slot. For details, see Table 6.

Table 6 Redis commands restricted in cluster DCS instances.

Category

Description

Set

SINTER

Returns the members of the set resulting from the intersection of all the given sets.

SINTERSTORE

Equal to SINTER, but instead of returning the result set, it is stored in destination.

SUNION

Returns the members of the set resulting from the union of all the given sets.

SUNIONSTORE

Equal to SUNION, but instead of returning the result set, it is stored in destination.

SDIFF

Returns the members of the set resulting from the difference between the first set and all the successive sets.

SDIFFSTORE

Equal to SDIFF, but instead of returning the result set, it is stored in destination.

SMOVE

Moves member from the set at source to the set at destination.

Sorted Set

ZUNIONSTORE

Computes the union of numkeys sorted sets given by the specified keys.

ZINTERSTORE

Computes the intersection of numkeys sorted sets given by the specified keys.

HyperLogLog

PFCOUNT

Returns the approximated cardinality computed by the HyperLogLog data structure stored at the specified variable.

PFMERGE

Merges multiple HyperLogLog values into a unique value.

List

BRPOPLPUSH

The blocking variant of RPOPLPUSH. When source contains elements, this command behaves exactly like RPOPLPUSH.

Key

RENAME

Renames key to newkey.

RENAMENX

Renames key to newkey if newkey does not yet exist.

BITOP

Performs a bitwise operation between multiple keys (containing string values) and stores the result in the destination key.

RPOPLPUSH

Returns and removes the last element (tail) of the list stored at source, and pushes the element at the first element (head) of the list stored at destination.

String

MSETNX

Sets the given keys to their respective values.

NOTE:

While running commands that take a long time to run, such as FLUSHALL, DCS instances may not respond to other commands and change to the faulty state. After the command finishes executing, the instance will return to normal.

Other Command Usage Restrictions

Key commands:

In case of a large amount of cached data, running a Keys command may block the execution of other commands for a long time or occupy exceptionally large memory. Therefore, when running a Keys command, describe the exact pattern and do not use fuzzy keys *. keys * can be used during commissioning or when the number of keys does not exceed 5 million. Otherwise, the service cannot run properly.

Server commands:

  • While running commands that take a long time to run, such as FLUSHALL, DCS instances may not respond to other commands and change to the faulty state. After the command finishes executing, the instance will return to normal.
  • When the FLUSHDB or FLUSHALL command is run, execution of other service commands may be blocked for a long time in case of a large amount of cached data.

EVAL and EVALSHA commands:

  • When the EVAL or EVALSHA command is run, at least one key must be contained in the command parameter. Otherwise, the error message "ERR eval/evalsha numkeys must be bigger than zero in redis cluster mode" is displayed.
  • When the EVAL or EVALSHA command is run, a cluster DCS Redis instance uses the first key to compute slots. Ensure that the keys to be operated in your code are in the same slot. For details, visit http://redis.io/commands.
  • For the EVAL command:
    • You are advised to learn the Lua script features of Redis before running the EVAL command. For details, see http://redisbook.readthedocs.io/en/latest/feature/scripting.html.
    • The execution timeout time of a Lua script is 5 seconds. Time-consuming statements such as long-time sleep and large loop statements should be avoided.
    • When calling a Lua script, do not use random functions to specify keys. Otherwise, the execution results are inconsistent on the master and standby nodes.

Others:

  • The time limit for executing a Redis command is 15 seconds. To prevent other services from failing, a master/replica switchover will be triggered after the command execution times out.
  • Cluster DCS Redis instances purchased before July 10, 2018 must be upgraded to support the following commands:

    SINTER, SDIFF, SUNION, PFCOUNT, PFMERGE, SINTERSTORE, SUNIONSTORE, SDIFFSTORE, SMOVE, BLPOP, BRPOP, BRPOPLPUSH, ZUNIONSTORE, ZINTERSTORE, EVAL, EVALSHA, BITOP, RENAME, RENAMENX, RPOPLPUSH, MSETNX, SCRIPT LOAD, SCRIPT KILL, SCRIPT EXISTS, SCRIPT FLUSH.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel