Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

SORT_RO

Last updated
SORT_RO key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC | DESC] [ALPHA]
Group
Server
Complexity
O(N + M log M) where N is the number of elements and M the number sorted
Arity
-2 (at least 2 words, counting the command name)
Flags
read-only, slow
Keys
first 1, last 1, step 1
HotKV Cloud
All plans
On-Premise
no license needed

SORT_RO is SORT without STORE. Because it never writes, it is flagged read-only: you can send it to a replica, and ACL users limited to read commands can run it. All other options and replies are those of SORT.

An array of bulk strings, with nil (RESP2) or null (RESP3) for a missing GET value. An empty array when key does not exist. Passing STORE gets ERR syntax error; the other errors are those of SORT.

127.0.0.1:6379> RPUSH scores 30 4 120 15
(integer) 4
127.0.0.1:6379> SORT_RO scores DESC
1) "120"
2) "30"
3) "15"
4) "4"
127.0.0.1:6379> SORT_RO scores STORE out
(error) ERR syntax error

Same as Redis 7 and Valkey 8.

SORT, READONLY