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. For more information, see Enable the direct connection mode and Features of proxy servers. Take note of the following rules:
  • Some Redis Cluster clients, such as stackExchange.redis client, do not support SELECT commands in direct connection mode. You can set the cluster_compat_enable parameter to 0 and restart the clients to disable the compatibility with the Redis Cluster syntax. For more information, see Parameter overview. You can also select other clients that support the command, such as Jedis client.
  • If you want to run the MULTI or EXEC commands by using the JedisCluster client, you must use the proxy mode. However, this mode cannot guarantee the atomicity of transactions.

Unsupported commands

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

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 Lua scripts

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 make sure that all operations in a Lua script are performed in the same hash slot, ApsaraDB for Redis imposes the following limits on a Lua script:

Note If an EVAL command fails to run, for example, the "ERR command eval not support for normal user" message is returned, upgrade the minor version of the ApsaraDB for Redis instance to the latest. For more information, see Upgrade 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 a 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 commands that you want to run. If the keys are not included in a command, 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.

Other limits

  • You can run the CLIENT LIST command to retrieve information about the connections to a specific proxy server. The following list describes the response:
    • 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 on proxy nodes 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 do not run the WATCH command before a transaction is executed and each command in the transaction processes only one key, the keys processed by all commands in the transaction can be distributed to different hash slots. You can run the commands in the same manner as you run the commands in a Redis database that is connected without a proxy server. In other scenarios, the keys that are processed by all commands in a transaction must be in the same hash slot.
    • 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.