From 4b2247645443ba27a3f5dc65a92735a406bac9f8 Mon Sep 17 00:00:00 2001 From: dvora-h <67596500+dvora-h@users.noreply.github.com> Date: Mon, 14 Mar 2022 15:57:58 +0200 Subject: Add support for SORT_RO (#1858) * add sort_ro * mark test as onlynon cluster * delete mark test as onlynoncluster * skip test --- redis/commands/core.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'redis/commands/core.py') diff --git a/redis/commands/core.py b/redis/commands/core.py index 56d6fa9..c367827 100644 --- a/redis/commands/core.py +++ b/redis/commands/core.py @@ -2724,6 +2724,39 @@ class ListCommands(CommandsProtocol): options = {"groups": len(get) if groups else None} return self.execute_command("SORT", *pieces, **options) + def sort_ro( + self, + key: str, + start: Optional[int] = None, + num: Optional[int] = None, + by: Optional[str] = None, + get: Optional[List[str]] = None, + desc: bool = False, + alpha: bool = False, + ) -> list: + """ + Returns the elements contained in the list, set or sorted set at key. + (read-only variant of the SORT command) + + ``start`` and ``num`` allow for paging through the sorted data + + ``by`` allows using an external key to weight and sort the items. + Use an "*" to indicate where in the key the item value is located + + ``get`` allows for returning items from external keys rather than the + sorted data itself. Use an "*" to indicate where in the key + the item value is located + + ``desc`` allows for reversing the sort + + ``alpha`` allows for sorting lexicographically rather than numerically + + For more information check https://redis.io/commands/sort_ro + """ + return self.sort( + key, start=start, num=num, by=by, get=get, desc=desc, alpha=alpha + ) + AsyncListCommands = ListCommands -- cgit v1.2.1