Back to Redis

SORT_RO

content/commands/sort_ro.md

latest1.7 KB
Original Source

Read-only variant of the [SORT]({{< relref "/commands/sort" >}}) command. It is exactly like the original [SORT]({{< relref "/commands/sort" >}}) but refuses the STORE option and can safely be used in read-only replicas.

Since the original [SORT]({{< relref "/commands/sort" >}}) has a STORE option it is technically flagged as a writing command in the Redis command table. For this reason read-only replicas in a Redis Cluster will redirect it to the master instance even if the connection is in read-only mode (see the [READONLY]({{< relref "/commands/readonly" >}}) command of Redis Cluster).

The SORT_RO variant was introduced in order to allow [SORT]({{< relref "/commands/sort" >}}) behavior in read-only replicas without breaking compatibility on command flags.

See original [SORT]({{< relref "/commands/sort" >}}) for more details.

Examples

SORT_RO mylist BY weight_*->fieldname GET object_*->fieldname

Redis Software and Redis Cloud compatibility

| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | |

Return information

{{< multitabs id="sort-ro-return-info" tab1="RESP2" tab2="RESP3" >}}

Array reply: a list of sorted elements.

-tab-sep-

Array reply: a list of sorted elements.

{{< /multitabs >}}