Skip to content

Commit 24a9dcf

Browse files
committed
fix: add other hash commands
1 parent 8bb4855 commit 24a9dcf

21 files changed

+712
-13
lines changed

mint.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@
237237
"redis/sdks/ts/commands/hash/hdel",
238238
"redis/sdks/ts/commands/hash/hexists",
239239
"redis/sdks/ts/commands/hash/hexpire",
240+
"redis/sdks/ts/commands/hash/hexpireat",
241+
"redis/sdks/ts/commands/hash/hexpiretime",
240242
"redis/sdks/ts/commands/hash/hget",
241243
"redis/sdks/ts/commands/hash/hgetall",
242244
"redis/sdks/ts/commands/hash/hincrby",
@@ -247,8 +249,14 @@
247249
"redis/sdks/ts/commands/hash/hrandfield",
248250
"redis/sdks/ts/commands/hash/hscan",
249251
"redis/sdks/ts/commands/hash/hset",
252+
"redis/sdks/ts/commands/hash/persist",
253+
"redis/sdks/ts/commands/hash/hpexpire",
254+
"redis/sdks/ts/commands/hash/hpexpireat",
255+
"redis/sdks/ts/commands/hash/hpexpiretime",
256+
"redis/sdks/ts/commands/hash/hpttl",
250257
"redis/sdks/ts/commands/hash/hsetnx",
251258
"redis/sdks/ts/commands/hash/hstrlen",
259+
"redis/sdks/ts/commands/hash/httl",
252260
"redis/sdks/ts/commands/hash/hvals"
253261
]
254262
},
@@ -467,6 +475,8 @@
467475
"redis/sdks/py/commands/hash/hdel",
468476
"redis/sdks/py/commands/hash/hexists",
469477
"redis/sdks/py/commands/hash/hexpire",
478+
"redis/sdks/ts/commands/hash/hexpireat",
479+
"redis/sdks/ts/commands/hash/hexpiretime",
470480
"redis/sdks/py/commands/hash/hget",
471481
"redis/sdks/py/commands/hash/hgetall",
472482
"redis/sdks/py/commands/hash/hincrby",
@@ -477,9 +487,15 @@
477487
"redis/sdks/py/commands/hash/hrandfield",
478488
"redis/sdks/py/commands/hash/hscan",
479489
"redis/sdks/py/commands/hash/hset",
490+
"redis/sdks/ts/commands/hash/persist",
491+
"redis/sdks/ts/commands/hash/hpexpire",
492+
"redis/sdks/ts/commands/hash/hpexpireat",
493+
"redis/sdks/ts/commands/hash/hpexpiretime",
494+
"redis/sdks/ts/commands/hash/hpttl",
480495
"redis/sdks/py/commands/hash/hmset",
481496
"redis/sdks/py/commands/hash/hsetnx",
482497
"redis/sdks/py/commands/hash/hstrlen",
498+
"redis/sdks/ts/commands/hash/httl",
483499
"redis/sdks/py/commands/hash/hvals"
484500
]
485501
},

redis/sdks/py/commands/hash/hexpire.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ description: Set a timeout on a hash field in seconds.
3636
## Response
3737

3838
<ResponseField type="List[int]" required>
39-
A list of integers indicating the number of fields for which the expiry was successfully set.
39+
A list of integers indicating whether the expiry was successfully set.
4040

4141
- `-2` if the field does not exist in the hash or if key doesn't exist.
4242
- `0` if the expiration was not set due to the condition.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: HEXPIREAT
3+
description: Sets an expiration time for field(s) in a hash in seconds since the Unix epoch.
4+
---
5+
6+
## Arguments
7+
8+
<ParamField body="key" type="str" required>
9+
The key of the hash.
10+
</ParamField>
11+
12+
<ParamField body="fields" type="Union[str, List[str]]" required>
13+
The field or list of fields to set an expiration time for.
14+
</ParamField>
15+
16+
<ParamField body="timestamp" type="int" required>
17+
The expiration time as a Unix timestamp in seconds.
18+
</ParamField>
19+
20+
<ParamField body="nx" type="bool" optional>
21+
Set expiry only when the field has no expiry. Defaults to `False`.
22+
</ParamField>
23+
24+
<ParamField body="xx" type="bool" optional>
25+
Set expiry only when the field has an existing expiry. Defaults to `False`.
26+
</ParamField>
27+
28+
<ParamField body="gt" type="bool" optional>
29+
Set expiry only when the new expiry is greater than the current one. Defaults to `False`.
30+
</ParamField>
31+
32+
<ParamField body="lt" type="bool" optional>
33+
Set expiry only when the new expiry is less than the current one. Defaults to `False`.
34+
</ParamField>
35+
36+
## Response
37+
38+
<ResponseField type="List[int]" required>
39+
A list of integers indicating whether the expiry was successfully set.
40+
41+
- `-2` if the field does not exist in the hash or if the key doesn't exist.
42+
- `0` if the expiration was not set due to the condition.
43+
- `1` if the expiration was successfully set.
44+
- `2` if called with 0 seconds/milliseconds or a past Unix time.
45+
</ResponseField>
46+
47+
<RequestExample>
48+
```py Example
49+
redis.hset(hash_name, field, value)
50+
assert redis.hexpireat(hash_name, field, int(time.time()) + 10) == [1]
51+
```
52+
</RequestExample>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: HEXPIRETIME
3+
description: Retrieves the expiration time of field(s) in a hash in seconds.
4+
---
5+
6+
## Arguments
7+
8+
<ParamField body="key" type="str" required>
9+
The key of the hash.
10+
</ParamField>
11+
12+
<ParamField body="fields" type="Union[str, List[str]]" required>
13+
The field or list of fields to retrieve the expiration time for.
14+
</ParamField>
15+
16+
## Response
17+
18+
<ResponseField type="List[int]" required>
19+
A list of integers representing the expiration time in seconds since the Unix epoch.
20+
21+
- `-2` if the field does not exist in the hash or if the key doesn't exist.
22+
- `-1` if the field exists but has no associated expiration.
23+
</ResponseField>
24+
25+
<RequestExample>
26+
```py Example
27+
redis.hset(hash_name, field, value)
28+
redis.hexpireat(hash_name, field, int(time.time()) + 10)
29+
30+
assert redis.hexpiretime(hash_name, field) == [1697059200]
31+
```
32+
</RequestExample>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: HPERSIST
3+
description: Remove the expiration from one or more hash fields.
4+
---
5+
6+
## Arguments
7+
8+
<ParamField body="key" type="str" required>
9+
The key of the hash.
10+
</ParamField>
11+
12+
<ParamField body="fields" type="Union[str, List[str]]" required>
13+
The field or list of fields within the hash to remove the expiry from.
14+
</ParamField>
15+
16+
## Response
17+
18+
<ResponseField type="List[int]" required>
19+
A list of integers indicating the result for each field:
20+
21+
- `-2` if the field does not exist in the hash or if the key doesn't exist.
22+
- `-1` if the field exists but has no associated expiration set.
23+
- `1` if the expiration was successfully removed.
24+
25+
For more details, see [HPERSIST documentation](https://redis.io/commands/hpersist).
26+
</ResponseField>
27+
28+
<RequestExample>
29+
```py Example
30+
redis.hset(hash_name, field, value)
31+
redis.hpexpire(hash_name, field, 1000)
32+
33+
assert redis.hpersist(hash_name, field) == [1]
34+
```
35+
</RequestExample>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: HPEXPIRE
3+
description: Set a timeout on a hash field in milliseconds.
4+
---
5+
6+
## Arguments
7+
8+
<ParamField body="key" type="str" required>
9+
The key of the hash.
10+
</ParamField>
11+
12+
<ParamField body="fields" type="Union[str, List[str]]" required>
13+
The field or list of fields within the hash to set the expiry for.
14+
</ParamField>
15+
16+
<ParamField body="milliseconds" type="Union[int, datetime.timedelta]" required>
17+
The timeout in milliseconds as an integer or a `datetime.timedelta` object.
18+
</ParamField>
19+
20+
<ParamField body="nx" type="bool" optional>
21+
Set expiry only when the field has no expiry. Defaults to `False`.
22+
</ParamField>
23+
24+
<ParamField body="xx" type="bool" optional>
25+
Set expiry only when the field has an existing expiry. Defaults to `False`.
26+
</ParamField>
27+
28+
<ParamField body="gt" type="bool" optional>
29+
Set expiry only when the new expiry is greater than the current one. Defaults to `False`.
30+
</ParamField>
31+
32+
<ParamField body="lt" type="bool" optional>
33+
Set expiry only when the new expiry is less than the current one. Defaults to `False`.
34+
</ParamField>
35+
36+
## Response
37+
38+
<ResponseField type="List[int]" required>
39+
A list of integers indicating whether the expiry was successfully set.
40+
41+
- `-2` if the field does not exist in the hash or if key doesn't exist.
42+
- `0` if the expiration was not set due to the condition.
43+
- `1` if the expiration was successfully set.
44+
- `2` if called with 0 seconds/milliseconds or a past Unix time.
45+
46+
For more details, see [HPEXPIRE documentation](https://redis.io/commands/hpexpire).
47+
</ResponseField>
48+
49+
<RequestExample>
50+
```py Example
51+
redis.hset(hash_name, field, value)
52+
53+
assert redis.hpexpire(hash_name, field, 1000) == [1]
54+
```
55+
</RequestExample>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: HPEXPIREAT
3+
description: Sets an expiration time for field(s) in a hash in milliseconds since the Unix epoch.
4+
---
5+
6+
## Arguments
7+
8+
<ParamField body="key" type="str" required>
9+
The key of the hash.
10+
</ParamField>
11+
12+
<ParamField body="fields" type="Union[str, List[str]]" required>
13+
The field or list of fields to set an expiration time for.
14+
</ParamField>
15+
16+
<ParamField body="timestamp" type="int" required>
17+
The expiration time as a Unix timestamp in milliseconds.
18+
</ParamField>
19+
20+
<ParamField body="nx" type="bool" optional>
21+
Set expiry only when the field has no expiry. Defaults to `False`.
22+
</ParamField>
23+
24+
<ParamField body="xx" type="bool" optional>
25+
Set expiry only when the field has an existing expiry. Defaults to `False`.
26+
</ParamField>
27+
28+
<ParamField body="gt" type="bool" optional>
29+
Set expiry only when the new expiry is greater than the current one. Defaults to `False`.
30+
</ParamField>
31+
32+
<ParamField body="lt" type="bool" optional>
33+
Set expiry only when the new expiry is less than the current one. Defaults to `False`.
34+
</ParamField>
35+
36+
## Response
37+
38+
<ResponseField type="List[int]" required>
39+
A list of integers indicating whether the expiry was successfully set.
40+
41+
- `-2` if the field does not exist in the hash or if the key doesn't exist.
42+
- `0` if the expiration was not set due to the condition.
43+
- `1` if the expiration was successfully set.
44+
- `2` if called with 0 seconds/milliseconds or a past Unix time.
45+
</ResponseField>
46+
47+
<RequestExample>
48+
```py Example
49+
redis.hset(hash_name, field, value)
50+
assert redis.hpexpireat(hash_name, field, int(time.time() * 1000) + 1000) == [1]
51+
```
52+
</RequestExample>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: HPEXPIRETIME
3+
description: Retrieves the expiration time of a field in a hash in milliseconds.
4+
---
5+
6+
## Arguments
7+
8+
<ParamField body="key" type="str" required>
9+
The key of the hash.
10+
</ParamField>
11+
12+
<ParamField body="fields" type="Union[str, List[str]]" required>
13+
The field or list of fields to retrieve the expiration time for.
14+
</ParamField>
15+
16+
## Response
17+
18+
<ResponseField type="List[int]" required>
19+
A list of integers representing the expiration time in milliseconds since the Unix epoch.
20+
21+
- `-2` if the field does not exist in the hash or if the key doesn't exist.
22+
- `-1` if the field exists but has no associated expiration.
23+
</ResponseField>
24+
25+
<RequestExample>
26+
```py Example
27+
redis.hset(hash_name, field, value)
28+
redis.hpexpireat(hash_name, field, int(time.time() * 1000) + 1000)
29+
30+
assert redis.hpexpiretime(hash_name, field) == [1697059200000]
31+
```
32+
</RequestExample>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: HPTTL
3+
description: Retrieves the remaining time-to-live (TTL) for field(s) in a hash in milliseconds.
4+
---
5+
6+
## Arguments
7+
8+
<ParamField body="key" type="str" required>
9+
The key of the hash.
10+
</ParamField>
11+
12+
<ParamField body="fields" type="Union[str, List[str]]" required>
13+
The field or list of fields to retrieve the TTL for.
14+
</ParamField>
15+
16+
## Response
17+
18+
<ResponseField type="List[int]" required>
19+
A list of integers representing the remaining TTL in milliseconds for each field.
20+
21+
- `-2` if the field does not exist in the hash or if the key doesn't exist.
22+
- `-1` if the field exists but has no associated expiration.
23+
</ResponseField>
24+
25+
<RequestExample>
26+
```py Example
27+
redis.hset(hash_name, field, value)
28+
redis.hpexpire(hash_name, field, 1000)
29+
30+
assert redis.hpttl(hash_name, field) == [950]
31+
```
32+
</RequestExample>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: HTTL
3+
description: Retrieves the remaining time-to-live (TTL) for field(s) in a hash in seconds.
4+
---
5+
6+
## Arguments
7+
8+
<ParamField body="key" type="str" required>
9+
The key of the hash.
10+
</ParamField>
11+
12+
<ParamField body="fields" type="Union[str, List[str]]" required>
13+
The field or list of fields to retrieve the TTL for.
14+
</ParamField>
15+
16+
## Response
17+
18+
<ResponseField type="List[int]" required>
19+
A list of integers representing the remaining TTL in seconds for each field.
20+
21+
- `-2` if the field does not exist in the hash or if the key doesn't exist.
22+
- `-1` if the field exists but has no associated expiration.
23+
</ResponseField>
24+
25+
<RequestExample>
26+
```py Example
27+
redis.hset(hash_name, field, value)
28+
redis.hexpire(hash_name, field, 10)
29+
30+
assert redis.httl(hash_name, field) == [9]
31+
```
32+
</RequestExample>

0 commit comments

Comments
 (0)