summaryrefslogtreecommitdiff
path: root/redis/commands/core.py
diff options
context:
space:
mode:
authordvora-h <67596500+dvora-h@users.noreply.github.com>2022-03-14 15:57:58 +0200
committerGitHub <noreply@github.com>2022-03-14 15:57:58 +0200
commit4b2247645443ba27a3f5dc65a92735a406bac9f8 (patch)
tree280f5b544f5e33a6c7c5defc2f81830996cd73f1 /redis/commands/core.py
parent160a7f6b951d2a11c17431cab34ee0457e128218 (diff)
downloadredis-py-4b2247645443ba27a3f5dc65a92735a406bac9f8.tar.gz
Add support for SORT_RO (#1858)
* add sort_ro * mark test as onlynon cluster * delete mark test as onlynoncluster * skip test
Diffstat (limited to 'redis/commands/core.py')
-rw-r--r--redis/commands/core.py33
1 files changed, 33 insertions, 0 deletions
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