-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds sort command to python Co-authored-by: Yury-Fridlyand Co-authored-by: Shoham Elias Co-authored-by: Aaron Co-authored-by: ikolomi
- Loading branch information
Showing
12 changed files
with
640 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright GLIDE-for-Redis Project Contributors - SPDX Identifier: Apache-2.0 | ||
|
||
from enum import Enum | ||
from typing import List, Optional, Union | ||
|
||
|
||
class Limit: | ||
""" | ||
Represents a limit argument for range queries in various Redis commands. | ||
The `LIMIT` argument is commonly used to specify a subset of results from the matching elements, | ||
similar to the `LIMIT` clause in SQL (e.g., `SELECT LIMIT offset, count`). | ||
This class can be utilized in multiple Redis commands that support limit options, | ||
such as [ZRANGE](https://valkey.io/commands/zrange), [SORT](https://valkey.io/commands/sort/), and others. | ||
Args: | ||
offset (int): The starting position of the range, zero based. | ||
count (int): The maximum number of elements to include in the range. | ||
A negative count returns all elements from the offset. | ||
Examples: | ||
>>> limit = Limit(0, 10) # Fetch the first 10 elements | ||
>>> limit = Limit(5, -1) # Fetch all elements starting from the 5th element | ||
""" | ||
|
||
def __init__(self, offset: int, count: int): | ||
self.offset = offset | ||
self.count = count | ||
|
||
|
||
class OrderBy(Enum): | ||
""" | ||
SORT order options: options for sorting elements. | ||
""" | ||
|
||
ASC = "ASC" | ||
""" | ||
ASC: Sort in ascending order. | ||
""" | ||
|
||
DESC = "DESC" | ||
""" | ||
DESC: Sort in descending order. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.