Skip to content

Commit 0c7f3b4

Browse files
committed
python: Update ExpiryType enum references in hash field expiration docs
Replace deprecated ExpiryType enum values with new names in docstrings: - EX → SEC - PX → MILLSEC - EXAT → UNIX_SEC - PXAT → UNIX_MILLSEC - KEEPTTL → KEEP_TTL Updates documentation for hash field expiration commands in both async and sync clients. Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
1 parent a6c64bb commit 0c7f3b4

File tree

2 files changed

+42
-42
lines changed
  • python
    • glide-async/python/glide/async_commands
    • glide-sync/glide_sync/sync_commands

2 files changed

+42
-42
lines changed

python/glide-async/python/glide/async_commands/core.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ async def httl(self, key: TEncodable, fields: List[TEncodable]) -> List[int]:
11201120
- `-2`: field does not exist or key does not exist
11211121
11221122
Examples:
1123-
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.EX, 10))
1123+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
11241124
>>> await client.httl("my_hash", ["field1", "field2", "non_existent_field"])
11251125
[9, 9, -2] # field1 and field2 have ~9 seconds left, non_existent_field doesn't exist
11261126
@@ -1150,7 +1150,7 @@ async def hpttl(self, key: TEncodable, fields: List[TEncodable]) -> List[int]:
11501150
- `-2`: field does not exist or key does not exist
11511151
11521152
Examples:
1153-
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.PX, 10000))
1153+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.MILLSEC, 10000))
11541154
>>> await client.hpttl("my_hash", ["field1", "field2", "non_existent_field"])
11551155
[9500, 9500, -2] # field1 and field2 have ~9500 milliseconds left, non_existent_field doesn't exist
11561156
@@ -1182,7 +1182,7 @@ async def hexpiretime(self, key: TEncodable, fields: List[TEncodable]) -> List[i
11821182
Examples:
11831183
>>> import time
11841184
>>> future_timestamp = int(time.time()) + 60 # 60 seconds from now
1185-
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.EXAT, future_timestamp))
1185+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.UNIX_SEC, future_timestamp))
11861186
>>> await client.hexpiretime("my_hash", ["field1", "field2", "non_existent_field"])
11871187
[future_timestamp, future_timestamp, -2] # field1 and field2 expire at future_timestamp, non_existent_field doesn't exist
11881188
@@ -1216,7 +1216,7 @@ async def hpexpiretime(
12161216
Examples:
12171217
>>> import time
12181218
>>> future_timestamp_ms = int(time.time() * 1000) + 60000 # 60 seconds from now in milliseconds
1219-
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.PXAT, future_timestamp_ms))
1219+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.UNIX_MILLSEC, future_timestamp_ms))
12201220
>>> await client.hpexpiretime("my_hash", ["field1", "field2", "non_existent_field"])
12211221
[future_timestamp_ms, future_timestamp_ms, -2] # field1 and field2 expire at future_timestamp_ms, non_existent_field doesn't exist
12221222
@@ -1249,17 +1249,17 @@ async def hsetex(
12491249
- ONLY_IF_ALL_EXIST (FXX): Only set fields if all of them already exist.
12501250
- ONLY_IF_NONE_EXIST (FNX): Only set fields if none of them already exist.
12511251
expiry (Optional[ExpirySet]): Expiration options for the fields:
1252-
- EX: Expiration time in seconds.
1253-
- PX: Expiration time in milliseconds.
1254-
- EXAT: Absolute expiration time in seconds (Unix timestamp).
1255-
- PXAT: Absolute expiration time in milliseconds (Unix timestamp).
1256-
- KEEPTTL: Retain existing TTL.
1252+
- SEC (EX): Expiration time in seconds.
1253+
- MILLSEC (PX): Expiration time in milliseconds.
1254+
- UNIX_SEC (EXAT): Absolute expiration time in seconds (Unix timestamp).
1255+
- UNIX_MILLSEC (PXAT): Absolute expiration time in milliseconds (Unix timestamp).
1256+
- KEEP_TTL (KEEPTTL): Retain existing TTL.
12571257
12581258
Returns:
12591259
int: 1 if all fields were set successfully, 0 if none were set due to conditional constraints.
12601260
12611261
Examples:
1262-
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.EX, 10))
1262+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
12631263
1 # All fields set with 10 second expiration
12641264
>>> await client.hsetex("my_hash", {"field3": "value3"}, field_conditional_change=HashFieldConditionalChange.ONLY_IF_ALL_EXIST)
12651265
1 # Field set because field already exists
@@ -1305,10 +1305,10 @@ async def hgetex(
13051305
key (TEncodable): The key of the hash.
13061306
fields (List[TEncodable]): The list of fields to retrieve from the hash.
13071307
expiry (Optional[ExpiryGetEx]): Expiration options for the retrieved fields:
1308-
- EX: Expiration time in seconds.
1309-
- PX: Expiration time in milliseconds.
1310-
- EXAT: Absolute expiration time in seconds (Unix timestamp).
1311-
- PXAT: Absolute expiration time in milliseconds (Unix timestamp).
1308+
- SEC (EX): Expiration time in seconds.
1309+
- MILLSEC (PX): Expiration time in milliseconds.
1310+
- UNIX_SEC (EXAT): Absolute expiration time in seconds (Unix timestamp).
1311+
- UNIX_MILLSEC (PXAT): Absolute expiration time in milliseconds (Unix timestamp).
13121312
- PERSIST: Remove expiration from the fields.
13131313
13141314
Returns:
@@ -1317,10 +1317,10 @@ async def hgetex(
13171317
If `key` does not exist, it is treated as an empty hash, and the function returns a list of null values.
13181318
13191319
Examples:
1320-
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.EX, 10))
1320+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
13211321
>>> await client.hgetex("my_hash", ["field1", "field2"])
13221322
[b"value1", b"value2"]
1323-
>>> await client.hgetex("my_hash", ["field1"], expiry=ExpiryGetEx(ExpiryTypeGetEx.EX, 20))
1323+
>>> await client.hgetex("my_hash", ["field1"], expiry=ExpiryGetEx(ExpiryTypeGetEx.SEC, 20))
13241324
[b"value1"] # field1 now has 20 second expiration
13251325
>>> await client.hgetex("my_hash", ["field1"], expiry=ExpiryGetEx(ExpiryTypeGetEx.PERSIST, None))
13261326
[b"value1"] # field1 expiration removed
@@ -1374,7 +1374,7 @@ async def hexpire(
13741374
- `2`: Field was deleted immediately (when seconds is 0 or timestamp is in the past).
13751375
13761376
Examples:
1377-
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.EX, 10))
1377+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
13781378
>>> await client.hexpire("my_hash", 20, ["field1", "field2"])
13791379
[1, 1] # Both fields' expiration set to 20 seconds
13801380
>>> await client.hexpire("my_hash", 30, ["field1"], option=ExpireOptions.NewExpiryGreaterThanCurrent)
@@ -1420,7 +1420,7 @@ async def hpersist(self, key: TEncodable, fields: List[TEncodable]) -> List[int]
14201420
- `-2`: Field does not exist or key does not exist.
14211421
14221422
Examples:
1423-
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.EX, 10))
1423+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
14241424
>>> await client.hpersist("my_hash", ["field1", "field2"])
14251425
[1, 1] # Both fields made persistent
14261426
>>> await client.hpersist("my_hash", ["field1"])
@@ -1467,7 +1467,7 @@ async def hpexpire(
14671467
- `2`: Field was deleted immediately (when milliseconds is 0 or timestamp is in the past).
14681468
14691469
Examples:
1470-
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.PX, 10000))
1470+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.MILLSEC, 10000))
14711471
>>> await client.hpexpire("my_hash", 20000, ["field1", "field2"])
14721472
[1, 1] # Both fields' expiration set to 20000 milliseconds
14731473
>>> await client.hpexpire("my_hash", 30000, ["field1"], option=ExpireOptions.NewExpiryGreaterThanCurrent)
@@ -1528,7 +1528,7 @@ async def hexpireat(
15281528
Examples:
15291529
>>> import time
15301530
>>> future_timestamp = int(time.time()) + 60 # 60 seconds from now
1531-
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.EX, 10))
1531+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
15321532
>>> await client.hexpireat("my_hash", future_timestamp, ["field1", "field2"])
15331533
[1, 1] # Both fields' expiration set to future_timestamp
15341534
>>> past_timestamp = int(time.time()) - 60 # 60 seconds ago
@@ -1588,7 +1588,7 @@ async def hpexpireat(
15881588
Examples:
15891589
>>> import time
15901590
>>> future_timestamp_ms = int(time.time() * 1000) + 60000 # 60 seconds from now in milliseconds
1591-
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.PX, 10000))
1591+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.MILLSEC, 10000))
15921592
>>> await client.hpexpireat("my_hash", future_timestamp_ms, ["field1", "field2"])
15931593
[1, 1] # Both fields' expiration set to future_timestamp_ms
15941594
>>> past_timestamp_ms = int(time.time() * 1000) - 60000 # 60 seconds ago in milliseconds

python/glide-sync/glide_sync/sync_commands/core.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ def httl(self, key: TEncodable, fields: List[TEncodable]) -> List[int]:
10851085
- `-2`: field does not exist or key does not exist
10861086
10871087
Examples:
1088-
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.EX, 10))
1088+
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
10891089
>>> client.httl("my_hash", ["field1", "field2", "non_existent_field"])
10901090
[9, 9, -2] # field1 and field2 have ~9 seconds left, non_existent_field doesn't exist
10911091
@@ -1115,7 +1115,7 @@ def hpttl(self, key: TEncodable, fields: List[TEncodable]) -> List[int]:
11151115
- `-2`: field does not exist or key does not exist
11161116
11171117
Examples:
1118-
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.PX, 10000))
1118+
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.MILLSEC, 10000))
11191119
>>> client.hpttl("my_hash", ["field1", "field2", "non_existent_field"])
11201120
[9500, 9500, -2] # field1 and field2 have ~9500 milliseconds left, non_existent_field doesn't exist
11211121
@@ -1147,7 +1147,7 @@ def hexpiretime(self, key: TEncodable, fields: List[TEncodable]) -> List[int]:
11471147
Examples:
11481148
>>> import time
11491149
>>> future_timestamp = int(time.time()) + 60 # 60 seconds from now
1150-
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.EXAT, future_timestamp))
1150+
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.UNIX_SEC, future_timestamp))
11511151
>>> client.hexpiretime("my_hash", ["field1", "field2", "non_existent_field"])
11521152
[future_timestamp, future_timestamp, -2] # field1 and field2 expire at future_timestamp, non_existent_field doesn't exist
11531153
@@ -1179,7 +1179,7 @@ def hpexpiretime(self, key: TEncodable, fields: List[TEncodable]) -> List[int]:
11791179
Examples:
11801180
>>> import time
11811181
>>> future_timestamp_ms = int(time.time() * 1000) + 60000 # 60 seconds from now in milliseconds
1182-
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.PXAT, future_timestamp_ms))
1182+
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.UNIX_MILLSEC, future_timestamp_ms))
11831183
>>> client.hpexpiretime("my_hash", ["field1", "field2", "non_existent_field"])
11841184
[future_timestamp_ms, future_timestamp_ms, -2] # field1 and field2 expire at future_timestamp_ms, non_existent_field doesn't exist
11851185
@@ -1212,17 +1212,17 @@ def hsetex(
12121212
- ONLY_IF_ALL_EXIST (FXX): Only set fields if all of them already exist.
12131213
- ONLY_IF_NONE_EXIST (FNX): Only set fields if none of them already exist.
12141214
expiry (Optional[ExpirySet]): Expiration options for the fields:
1215-
- EX: Expiration time in seconds.
1216-
- PX: Expiration time in milliseconds.
1217-
- EXAT: Absolute expiration time in seconds (Unix timestamp).
1218-
- PXAT: Absolute expiration time in milliseconds (Unix timestamp).
1219-
- KEEPTTL: Retain existing TTL.
1215+
- SEC (EX): Expiration time in seconds.
1216+
- MILLSEC (PX): Expiration time in milliseconds.
1217+
- UNIX_SEC (EXAT): Absolute expiration time in seconds (Unix timestamp).
1218+
- UNIX_MILLSEC (PXAT): Absolute expiration time in milliseconds (Unix timestamp).
1219+
- KEEP_TTL (KEEPTTL): Retain existing TTL.
12201220
12211221
Returns:
12221222
int: 1 if all fields were set successfully, 0 if none were set due to conditional constraints.
12231223
12241224
Examples:
1225-
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.EX, 10))
1225+
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
12261226
1 # All fields set with 10 second expiration
12271227
>>> client.hsetex("my_hash", {"field3": "value3"}, field_conditional_change=HashFieldConditionalChange.ONLY_IF_ALL_EXIST)
12281228
1 # Field set because field already exists
@@ -1268,10 +1268,10 @@ def hgetex(
12681268
key (TEncodable): The key of the hash.
12691269
fields (List[TEncodable]): The list of fields to retrieve from the hash.
12701270
expiry (Optional[ExpiryGetEx]): Expiration options for the retrieved fields:
1271-
- EX: Expiration time in seconds.
1272-
- PX: Expiration time in milliseconds.
1273-
- EXAT: Absolute expiration time in seconds (Unix timestamp).
1274-
- PXAT: Absolute expiration time in milliseconds (Unix timestamp).
1271+
- SEC (EX): Expiration time in seconds.
1272+
- MILLSEC (PX): Expiration time in milliseconds.
1273+
- UNIX_SEC (EXAT): Absolute expiration time in seconds (Unix timestamp).
1274+
- UNIX_MILLSEC (PXAT): Absolute expiration time in milliseconds (Unix timestamp).
12751275
- PERSIST: Remove expiration from the fields.
12761276
12771277
Returns:
@@ -1280,10 +1280,10 @@ def hgetex(
12801280
If `key` does not exist, it is treated as an empty hash, and the function returns a list of null values.
12811281
12821282
Examples:
1283-
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.EX, 10))
1283+
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
12841284
>>> client.hgetex("my_hash", ["field1", "field2"])
12851285
[b"value1", b"value2"]
1286-
>>> client.hgetex("my_hash", ["field1"], expiry=ExpiryGetEx(ExpiryTypeGetEx.EX, 20))
1286+
>>> client.hgetex("my_hash", ["field1"], expiry=ExpiryGetEx(ExpiryTypeGetEx.SEC, 20))
12871287
[b"value1"] # field1 now has 20 second expiration
12881288
>>> client.hgetex("my_hash", ["field1"], expiry=ExpiryGetEx(ExpiryTypeGetEx.PERSIST, None))
12891289
[b"value1"] # field1 expiration removed
@@ -1337,7 +1337,7 @@ def hexpire(
13371337
- `2`: Field was deleted immediately (when seconds is 0 or timestamp is in the past).
13381338
13391339
Examples:
1340-
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.EX, 10))
1340+
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
13411341
>>> client.hexpire("my_hash", 20, ["field1", "field2"])
13421342
[1, 1] # Both fields' expiration set to 20 seconds
13431343
>>> client.hexpire("my_hash", 30, ["field1"], option=ExpireOptions.NewExpiryGreaterThanCurrent)
@@ -1383,7 +1383,7 @@ def hpersist(self, key: TEncodable, fields: List[TEncodable]) -> List[int]:
13831383
- `-2`: Field does not exist or key does not exist.
13841384
13851385
Examples:
1386-
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.EX, 10))
1386+
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
13871387
>>> client.hpersist("my_hash", ["field1", "field2"])
13881388
[1, 1] # Both fields made persistent
13891389
>>> client.hpersist("my_hash", ["field1"])
@@ -1430,7 +1430,7 @@ def hpexpire(
14301430
- `2`: Field was deleted immediately (when milliseconds is 0 or timestamp is in the past).
14311431
14321432
Examples:
1433-
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.PX, 10000))
1433+
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.MILLSEC, 10000))
14341434
>>> client.hpexpire("my_hash", 20000, ["field1", "field2"])
14351435
[1, 1] # Both fields' expiration set to 20000 milliseconds
14361436
>>> client.hpexpire("my_hash", 30000, ["field1"], option=ExpireOptions.NewExpiryGreaterThanCurrent)
@@ -1491,7 +1491,7 @@ def hexpireat(
14911491
Examples:
14921492
>>> import time
14931493
>>> future_timestamp = int(time.time()) + 60 # 60 seconds from now
1494-
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.EX, 10))
1494+
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
14951495
>>> client.hexpireat("my_hash", future_timestamp, ["field1", "field2"])
14961496
[1, 1] # Both fields' expiration set to future_timestamp
14971497
>>> past_timestamp = int(time.time()) - 60 # 60 seconds ago
@@ -1551,7 +1551,7 @@ def hpexpireat(
15511551
Examples:
15521552
>>> import time
15531553
>>> future_timestamp_ms = int(time.time() * 1000) + 60000 # 60 seconds from now in milliseconds
1554-
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.PX, 10000))
1554+
>>> client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.MILLSEC, 10000))
15551555
>>> client.hpexpireat("my_hash", future_timestamp_ms, ["field1", "field2"])
15561556
[1, 1] # Both fields' expiration set to future_timestamp_ms
15571557
>>> past_timestamp_ms = int(time.time() * 1000) - 60000 # 60 seconds ago in milliseconds

0 commit comments

Comments
 (0)