This topic describes the limits on commands supported by cluster instances. Cluster instances and standard instances use different architectures and follow different rules to run Redis commands.

Supported commands

Note The cluster instances of ApsaraDB for Redis support the direct connection mode and proxy mode. Take note of the following rule:
  • If you want to run the MULTI or EXEC commands by using a JedisCluster client, you must use the proxy mode.

Unsupported commands

  • SWAPDB
  • CLIENT ID
  • SORT, which is used together with the BY and GET options

Limited commands

Note To run the following commands on cluster instances, use hash tags to ensure that all keys are distributed in one hash slot. For more information, see Redis documentation.
Command group Command
HyperLogLog PFMERGE and PFCOUNT
Keys RENAME, RENAMENX, and SORT
Lists RPOPLPUSH, BRPOP, BLPOP, and BRPOPLPUSH
Scripting EVAL, EVALSHA, SCRIPT EXISTS, SCRIPT FLUSH, SCRIPT KILL, and SCRIPT LOAD
Strings MSETNX
Transaction DISCARD, EXEC, MULTI, UNWATCH, and WATCH

Limits on the SELECT command

Connection mode Description
Proxy mode The proxy mode supports the SELECT command. Take note that some Redis clients such as stackExchange.redis cannot distinguish the SELECT command. To resolve this issue, you can set the cluster_compat_enable parameter to 0 to disable the compatibility with the Redis Cluster syntax. Then, restart the clients and run the SELECT command again. For more information, see Modify the parameters of an ApsaraDB for Redis instance. You can also use other clients that support this command, such as the Jedis client.
Direct connection mode The direct connection mode does not support the SELECT command because of the limits of mainstream Redis clients such as the Jedis client.

Limits on Lua scripts

Warning The cluster architecture imposes limits on Lua scripts. When you change the architecture of an instance to the cluster architecture by performing a configuration change, the Lua scripts may be lost because the script content does not meet the requirements. You must back up the Lua scripts in advance.

You can use Lua scripts to process check-and-set (CAS) commands to improve the performance of ApsaraDB for Redis. You can combine multiple CAS commands in a Lua script and execute the script to implement CAS with higher efficiency. To ensure that all operations in a Lua script are performed in the same hash slot, the cluster instance of ApsaraDB for Redis imposes the following limits on a Lua script:

Note If an error message indicating that the EVAL command fails to run is returned, such as ERR command eval not support for normal user, update the minor version of the ApsaraDB for Redis instance to the latest version. For more information, see Update the minor version.
  • The Lua script uses the redis.call or redis.pcall function to run Redis commands. For Redis commands, all keys must be passed by using the KEYS array, which cannot be replaced by Lua variables. If you do not use the KEYS array to pass the keys, the following error message is returned:
    -ERR bad lua script for redis cluster, all the keys that the script uses should be passed using the KEYS array\r\n
  • All keys that the script uses must be allocated to the same hash slot. If the keys are allocated to different hash slots, the following error message is returned:
    -ERR eval/evalsha command keys must be in same slot\r\n
  • Keys must be included in all the commands that you want to run. Otherwise, the following error message is returned:
    -ERR for redis cluster, eval/evalsha number of keys can't be negative or zero\r\n
  • The following Pub/Sub commands are not supported: PSUBSCRIBE, PUBSUB, PUBLISH, PUNSUBSCRIBE, SUBSCRIBE, and UNSUBSCRIBE.
  • The UNPACK function is not supported.
Note If all the operations can be performed in the same hash slot and you want to break through the limits that the cluster architecture imposes on your Lua script, you can set the script_check_enable parameter to 0 in the ApsaraDB for Redis console. This way, the system does not check your Lua script at the backend. In this case, you still need to pass at least one key in the KEYS array so that the proxy server can route commands in the Lua script. For more information, see Modify the parameters of an ApsaraDB for Redis instance.

Other limits

  • You can run the CLIENT LIST command to retrieve information about the connections to the specified proxy server. The following list describes the fields in the command output:
    • The following fields have the same meaning as the fields in open source Redis: id, age, idle, addr, fd, name, db, multi, omem, and cmd.
    • The values of the sub and psub fields are the same. The values are 1 or 0.
    • The qbuf, qbuf-free, obl, and oll fields are reserved. You can ignore these fields.
  • You can run the CLIENT KILL command in the client kill ip:port or client kill addr ip:port format.
  • If you run commands on a cluster instance in proxy mode, a transaction can be split into multiple sub-transactions to ensure the compatibility with the master and replica architecture. In this case, the atomicity of the transaction cannot be ensured. If you run commands on a cluster instance in direct connection mode, the keys involved in a transaction must be in the same hash slot. This requirement is the same as that of open source Redis Cluster.
    Notice In proxy mode, if you run the WATCH command or a transaction involves commands that process multiple keys, such as the MSET command, the transaction will not be split. If all keys processed in the transaction are in the same hash slot, the atomicity of the transaction can be ensured.
    • The commands that process multiple keys include DEL, SORT, MGET, MSET, BITOP, EXISTS, MSETNX, RENAME, RENAMENX, BLPOP, BRPOP, RPOPLPUSH, BRPOPLPUSH, SMOVE, SUNION, SINTER, SDIFF, SUNIONSTORE, SINTERSTORE, SDIFFSTORE, ZUNIONSTORE, ZINTERSTORE, PFMERGE, and PFCOUNT.
    • The commands that are not supported in transactions include WATCH, UNWATCH, RANDOMKEY, KEYS, SUBSCRIBE, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, PUBLISH, PUBSUB, SCRIPT, EVAL, EVALSHA, SCAN, ISCAN, DBSIZE, ADMINAUTH, AUTH, PING, ECHO, FLUSHDB, FLUSHALL, MONITOR, IMONITOR, RIMONITOR, INFO, IINFO, RIINFO, CONFIG, SLOWLOG, TIME, and CLIENT.