sort_ro.3valkey - Man Page
Returns the sorted elements of a list, a set, or a sorted set.
Synopsis
SORT_RO
key [BY
pattern] [LIMIT
offset count] [GET
pattern [GET
pattern ...]] [ASC
| DESC
] [ALPHA
]
Description
Read-only variant of the SORT
command. It is exactly like the original SORT
but refuses the STORE
option and can safely be used in read-only replicas.
Since the original SORT
has a STORE
option it is technically flagged as a writing command in the Valkey command table. For this reason read-only replicas in a Valkey Cluster will redirect it to the master instance even if the connection is in read-only mode (see the READONLY
command of Valkey Cluster).
The SORT_RO
variant was introduced in order to allow SORT
behavior in read-only replicas without breaking compatibility on command flags.
See original SORT
for more details.
Reply
valkey-protocol(7) Array reply: a list of sorted elements.
Complexity
O(N+M*log(M)) where N is the number of elements in the list or set to sort, and M the number of returned elements. When the elements are not sorted, complexity is O(N).
Acl Categories
@dangerous @list @read @set @slow @sortedset
History
- Available since: 7.0.0
Examples
SORT_RO mylist BY weight_*->fieldname GET object_*->fieldname
See Also
copy(3valkey), del(3valkey), dump(3valkey), exists(3valkey), expire(3valkey), expireat(3valkey), expiretime(3valkey), keys(3valkey), migrate(3valkey), move(3valkey), object(3valkey), object-encoding(3valkey), object-freq(3valkey), object-help(3valkey), object-idletime(3valkey), object-refcount(3valkey), persist(3valkey), pexpire(3valkey), pexpireat(3valkey), pexpiretime(3valkey), pttl(3valkey), randomkey(3valkey), rename(3valkey), renamenx(3valkey), restore(3valkey), scan(3valkey), sort(3valkey), touch(3valkey), ttl(3valkey), type(3valkey), unlink(3valkey), wait(3valkey), waitaof(3valkey)