generated from mintlify/starter
-
Notifications
You must be signed in to change notification settings - Fork 87
Add hash expiration docs to the redis SDKs #430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,55 @@ | ||
| --- | ||
| title: HEXPIRE | ||
| description: Set a timeout on a hash field in seconds. | ||
| --- | ||
|
|
||
| ## Arguments | ||
|
|
||
| <ParamField body="key" type="str" required> | ||
| The key of the hash. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="fields" type="Union[str, List[str]]" required> | ||
| The field or list of fields within the hash to set the expiry for. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="seconds" type="Union[int, datetime.timedelta]" required> | ||
| The timeout in seconds as an integer or a `datetime.timedelta` object. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="nx" type="bool" optional> | ||
| Set expiry only when the field has no expiry. Defaults to `False`. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="xx" type="bool" optional> | ||
| Set expiry only when the field has an existing expiry. Defaults to `False`. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="gt" type="bool" optional> | ||
| Set expiry only when the new expiry is greater than the current one. Defaults to `False`. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="lt" type="bool" optional> | ||
| Set expiry only when the new expiry is less than the current one. Defaults to `False`. | ||
| </ParamField> | ||
|
|
||
| ## Response | ||
|
|
||
| <ResponseField type="List[int]" required> | ||
| A list of integers indicating whether the expiry was successfully set. | ||
|
|
||
| - `-2` if the field does not exist in the hash or if key doesn't exist. | ||
| - `0` if the expiration was not set due to the condition. | ||
| - `1` if the expiration was successfully set. | ||
| - `2` if called with 0 seconds/milliseconds or a past Unix time. | ||
|
|
||
| For more details, see [HEXPIRE documentation](https://redis.io/commands/hexpire). | ||
| </ResponseField> | ||
|
|
||
| <RequestExample> | ||
| ```py Example | ||
| redis.hset(hash_name, field, value) | ||
|
|
||
| assert redis.hexpire(hash_name, field, 1) == [1] | ||
| ``` | ||
| </RequestExample> |
This file contains hidden or 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,55 @@ | ||
| --- | ||
| title: HEXPIREAT | ||
| description: Sets an expiration time for field(s) in a hash in seconds since the Unix epoch. | ||
| --- | ||
|
|
||
| ## Arguments | ||
|
|
||
| <ParamField body="key" type="str" required> | ||
| The key of the hash. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="fields" type="Union[str, List[str]]" required> | ||
| The field or list of fields to set an expiration time for. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="timestamp" type="int" required> | ||
| The expiration time as a Unix timestamp in seconds. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="nx" type="bool" optional> | ||
| Set expiry only when the field has no expiry. Defaults to `False`. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="xx" type="bool" optional> | ||
| Set expiry only when the field has an existing expiry. Defaults to `False`. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="gt" type="bool" optional> | ||
| Set expiry only when the new expiry is greater than the current one. Defaults to `False`. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="lt" type="bool" optional> | ||
| Set expiry only when the new expiry is less than the current one. Defaults to `False`. | ||
| </ParamField> | ||
|
|
||
| ## Response | ||
|
|
||
| <ResponseField type="List[int]" required> | ||
| A list of integers indicating whether the expiry was successfully set. | ||
|
|
||
| - `-2` if the field does not exist in the hash or if the key doesn't exist. | ||
| - `0` if the expiration was not set due to the condition. | ||
| - `1` if the expiration was successfully set. | ||
| - `2` if called with 0 seconds/milliseconds or a past Unix time. | ||
|
|
||
| For more details, see [HEXPIREAT documentation](https://redis.io/commands/hexpireat). | ||
| </ResponseField> | ||
|
|
||
| <RequestExample> | ||
| ```py Example | ||
| redis.hset(hash_name, field, value) | ||
|
|
||
| assert redis.hexpireat(hash_name, field, int(time.time()) + 10) == [1] | ||
| ``` | ||
| </RequestExample> | ||
This file contains hidden or 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,34 @@ | ||
| --- | ||
| title: HEXPIRETIME | ||
| description: Retrieves the expiration time of field(s) in a hash in seconds. | ||
| --- | ||
|
|
||
| ## Arguments | ||
|
|
||
| <ParamField body="key" type="str" required> | ||
| The key of the hash. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="fields" type="Union[str, List[str]]" required> | ||
| The field or list of fields to retrieve the expiration time for. | ||
| </ParamField> | ||
|
|
||
| ## Response | ||
|
|
||
| <ResponseField type="List[int]" required> | ||
| A list of integers representing the expiration time in seconds since the Unix epoch. | ||
|
|
||
| - `-2` if the field does not exist in the hash or if the key doesn't exist. | ||
| - `-1` if the field exists but has no associated expiration. | ||
|
|
||
| For more details, see [HEXPIRETIME documentation](https://redis.io/commands/hexpiretime). | ||
| </ResponseField> | ||
|
|
||
| <RequestExample> | ||
| ```py Example | ||
| redis.hset(hash_name, field, value) | ||
| redis.hexpireat(hash_name, field, int(time.time()) + 10) | ||
|
|
||
| assert redis.hexpiretime(hash_name, field) == [1697059200] | ||
| ``` | ||
| </RequestExample> |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -24,6 +24,5 @@ redis.hset("myhash", values={ | |
| }) | ||
|
|
||
| assert redis.hkeys("myhash") == ["field1", "field2"] | ||
|
|
||
| ``` | ||
| </RequestExample> | ||
This file contains hidden or 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,35 @@ | ||
| --- | ||
| title: HPERSIST | ||
| description: Remove the expiration from one or more hash fields. | ||
| --- | ||
|
|
||
| ## Arguments | ||
|
|
||
| <ParamField body="key" type="str" required> | ||
| The key of the hash. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="fields" type="Union[str, List[str]]" required> | ||
| The field or list of fields within the hash to remove the expiry from. | ||
| </ParamField> | ||
|
|
||
| ## Response | ||
|
|
||
| <ResponseField type="List[int]" required> | ||
| A list of integers indicating the result for each field: | ||
|
|
||
| - `-2` if the field does not exist in the hash or if the key doesn't exist. | ||
| - `-1` if the field exists but has no associated expiration set. | ||
| - `1` if the expiration was successfully removed. | ||
|
|
||
| For more details, see [HPERSIST documentation](https://redis.io/commands/hpersist). | ||
| </ResponseField> | ||
|
|
||
| <RequestExample> | ||
| ```py Example | ||
| redis.hset(hash_name, field, value) | ||
| redis.hpexpire(hash_name, field, 1000) | ||
|
|
||
| assert redis.hpersist(hash_name, field) == [1] | ||
| ``` | ||
| </RequestExample> |
This file contains hidden or 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,55 @@ | ||
| --- | ||
| title: HPEXPIRE | ||
| description: Set a timeout on a hash field in milliseconds. | ||
| --- | ||
|
|
||
| ## Arguments | ||
|
|
||
| <ParamField body="key" type="str" required> | ||
| The key of the hash. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="fields" type="Union[str, List[str]]" required> | ||
| The field or list of fields within the hash to set the expiry for. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="milliseconds" type="Union[int, datetime.timedelta]" required> | ||
| The timeout in milliseconds as an integer or a `datetime.timedelta` object. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="nx" type="bool" optional> | ||
| Set expiry only when the field has no expiry. Defaults to `False`. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="xx" type="bool" optional> | ||
| Set expiry only when the field has an existing expiry. Defaults to `False`. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="gt" type="bool" optional> | ||
| Set expiry only when the new expiry is greater than the current one. Defaults to `False`. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="lt" type="bool" optional> | ||
| Set expiry only when the new expiry is less than the current one. Defaults to `False`. | ||
| </ParamField> | ||
|
|
||
| ## Response | ||
|
|
||
| <ResponseField type="List[int]" required> | ||
| A list of integers indicating whether the expiry was successfully set. | ||
|
|
||
| - `-2` if the field does not exist in the hash or if key doesn't exist. | ||
| - `0` if the expiration was not set due to the condition. | ||
| - `1` if the expiration was successfully set. | ||
| - `2` if called with 0 seconds/milliseconds or a past Unix time. | ||
|
|
||
| For more details, see [HPEXPIRE documentation](https://redis.io/commands/hpexpire). | ||
| </ResponseField> | ||
|
|
||
| <RequestExample> | ||
| ```py Example | ||
| redis.hset(hash_name, field, value) | ||
|
|
||
| assert redis.hpexpire(hash_name, field, 1000) == [1] | ||
| ``` | ||
| </RequestExample> |
This file contains hidden or 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,55 @@ | ||
| --- | ||
| title: HPEXPIREAT | ||
| description: Sets an expiration time for field(s) in a hash in milliseconds since the Unix epoch. | ||
| --- | ||
|
|
||
| ## Arguments | ||
|
|
||
| <ParamField body="key" type="str" required> | ||
| The key of the hash. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="fields" type="Union[str, List[str]]" required> | ||
| The field or list of fields to set an expiration time for. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="timestamp" type="int" required> | ||
| The expiration time as a Unix timestamp in milliseconds. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="nx" type="bool" optional> | ||
| Set expiry only when the field has no expiry. Defaults to `False`. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="xx" type="bool" optional> | ||
| Set expiry only when the field has an existing expiry. Defaults to `False`. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="gt" type="bool" optional> | ||
| Set expiry only when the new expiry is greater than the current one. Defaults to `False`. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="lt" type="bool" optional> | ||
| Set expiry only when the new expiry is less than the current one. Defaults to `False`. | ||
| </ParamField> | ||
|
|
||
| ## Response | ||
|
|
||
| <ResponseField type="List[int]" required> | ||
| A list of integers indicating whether the expiry was successfully set. | ||
|
|
||
| - `-2` if the field does not exist in the hash or if the key doesn't exist. | ||
| - `0` if the expiration was not set due to the condition. | ||
| - `1` if the expiration was successfully set. | ||
| - `2` if called with 0 seconds/milliseconds or a past Unix time. | ||
|
|
||
| For more details, see [HPEXPIREAT documentation](https://redis.io/commands/hpexpireat). | ||
| </ResponseField> | ||
|
|
||
| <RequestExample> | ||
| ```py Example | ||
| redis.hset(hash_name, field, value) | ||
|
|
||
| assert redis.hpexpireat(hash_name, field, int(time.time() * 1000) + 1000) == [1] | ||
| ``` | ||
| </RequestExample> |
This file contains hidden or 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,34 @@ | ||
| --- | ||
| title: HPEXPIRETIME | ||
| description: Retrieves the expiration time of a field in a hash in milliseconds. | ||
| --- | ||
|
|
||
| ## Arguments | ||
|
|
||
| <ParamField body="key" type="str" required> | ||
| The key of the hash. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="fields" type="Union[str, List[str]]" required> | ||
| The field or list of fields to retrieve the expiration time for. | ||
| </ParamField> | ||
|
|
||
| ## Response | ||
|
|
||
| <ResponseField type="List[int]" required> | ||
| A list of integers representing the expiration time in milliseconds since the Unix epoch. | ||
|
|
||
| - `-2` if the field does not exist in the hash or if the key doesn't exist. | ||
| - `-1` if the field exists but has no associated expiration. | ||
|
|
||
| For more details, see [HPEXPIRETIME documentation](https://redis.io/commands/hpexpiretime). | ||
| </ResponseField> | ||
|
|
||
| <RequestExample> | ||
| ```py Example | ||
| redis.hset(hash_name, field, value) | ||
| redis.hpexpireat(hash_name, field, int(time.time() * 1000) + 1000) | ||
|
|
||
| assert redis.hpexpiretime(hash_name, field) == [1697059200000] | ||
| ``` | ||
| </RequestExample> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.