diff --git a/mint.json b/mint.json index ef1fee28..805a6070 100644 --- a/mint.json +++ b/mint.json @@ -236,6 +236,9 @@ "pages": [ "redis/sdks/ts/commands/hash/hdel", "redis/sdks/ts/commands/hash/hexists", + "redis/sdks/ts/commands/hash/hexpire", + "redis/sdks/ts/commands/hash/hexpireat", + "redis/sdks/ts/commands/hash/hexpiretime", "redis/sdks/ts/commands/hash/hget", "redis/sdks/ts/commands/hash/hgetall", "redis/sdks/ts/commands/hash/hincrby", @@ -246,8 +249,14 @@ "redis/sdks/ts/commands/hash/hrandfield", "redis/sdks/ts/commands/hash/hscan", "redis/sdks/ts/commands/hash/hset", + "redis/sdks/ts/commands/hash/hpersist", + "redis/sdks/ts/commands/hash/hpexpire", + "redis/sdks/ts/commands/hash/hpexpireat", + "redis/sdks/ts/commands/hash/hpexpiretime", + "redis/sdks/ts/commands/hash/hpttl", "redis/sdks/ts/commands/hash/hsetnx", "redis/sdks/ts/commands/hash/hstrlen", + "redis/sdks/ts/commands/hash/httl", "redis/sdks/ts/commands/hash/hvals" ] }, @@ -465,6 +474,9 @@ "pages": [ "redis/sdks/py/commands/hash/hdel", "redis/sdks/py/commands/hash/hexists", + "redis/sdks/py/commands/hash/hexpire", + "redis/sdks/py/commands/hash/hexpireat", + "redis/sdks/py/commands/hash/hexpiretime", "redis/sdks/py/commands/hash/hget", "redis/sdks/py/commands/hash/hgetall", "redis/sdks/py/commands/hash/hincrby", @@ -475,9 +487,15 @@ "redis/sdks/py/commands/hash/hrandfield", "redis/sdks/py/commands/hash/hscan", "redis/sdks/py/commands/hash/hset", + "redis/sdks/py/commands/hash/hpersist", + "redis/sdks/py/commands/hash/hpexpire", + "redis/sdks/py/commands/hash/hpexpireat", + "redis/sdks/py/commands/hash/hpexpiretime", + "redis/sdks/py/commands/hash/hpttl", "redis/sdks/py/commands/hash/hmset", "redis/sdks/py/commands/hash/hsetnx", "redis/sdks/py/commands/hash/hstrlen", + "redis/sdks/py/commands/hash/httl", "redis/sdks/py/commands/hash/hvals" ] }, diff --git a/redis/sdks/py/commands/hash/hexpire.mdx b/redis/sdks/py/commands/hash/hexpire.mdx new file mode 100644 index 00000000..ca7ea3ed --- /dev/null +++ b/redis/sdks/py/commands/hash/hexpire.mdx @@ -0,0 +1,55 @@ +--- +title: HEXPIRE +description: Set a timeout on a hash field in seconds. +--- + +## Arguments + + + The key of the hash. + + + + The field or list of fields within the hash to set the expiry for. + + + + The timeout in seconds as an integer or a `datetime.timedelta` object. + + + + Set expiry only when the field has no expiry. Defaults to `False`. + + + + Set expiry only when the field has an existing expiry. Defaults to `False`. + + + + Set expiry only when the new expiry is greater than the current one. Defaults to `False`. + + + + Set expiry only when the new expiry is less than the current one. Defaults to `False`. + + +## Response + + + 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). + + + +```py Example +redis.hset(hash_name, field, value) + +assert redis.hexpire(hash_name, field, 1) == [1] +``` + diff --git a/redis/sdks/py/commands/hash/hexpireat.mdx b/redis/sdks/py/commands/hash/hexpireat.mdx new file mode 100644 index 00000000..8fb9d243 --- /dev/null +++ b/redis/sdks/py/commands/hash/hexpireat.mdx @@ -0,0 +1,55 @@ +--- +title: HEXPIREAT +description: Sets an expiration time for field(s) in a hash in seconds since the Unix epoch. +--- + +## Arguments + + + The key of the hash. + + + + The field or list of fields to set an expiration time for. + + + + The expiration time as a Unix timestamp in seconds. + + + + Set expiry only when the field has no expiry. Defaults to `False`. + + + + Set expiry only when the field has an existing expiry. Defaults to `False`. + + + + Set expiry only when the new expiry is greater than the current one. Defaults to `False`. + + + + Set expiry only when the new expiry is less than the current one. Defaults to `False`. + + +## Response + + + 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). + + + +```py Example +redis.hset(hash_name, field, value) + +assert redis.hexpireat(hash_name, field, int(time.time()) + 10) == [1] +``` + diff --git a/redis/sdks/py/commands/hash/hexpiretime.mdx b/redis/sdks/py/commands/hash/hexpiretime.mdx new file mode 100644 index 00000000..ac4242c3 --- /dev/null +++ b/redis/sdks/py/commands/hash/hexpiretime.mdx @@ -0,0 +1,34 @@ +--- +title: HEXPIRETIME +description: Retrieves the expiration time of field(s) in a hash in seconds. +--- + +## Arguments + + + The key of the hash. + + + + The field or list of fields to retrieve the expiration time for. + + +## Response + + + 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). + + + +```py Example +redis.hset(hash_name, field, value) +redis.hexpireat(hash_name, field, int(time.time()) + 10) + +assert redis.hexpiretime(hash_name, field) == [1697059200] +``` + diff --git a/redis/sdks/py/commands/hash/hkeys.mdx b/redis/sdks/py/commands/hash/hkeys.mdx index 0b8ab25f..01b4b1ca 100644 --- a/redis/sdks/py/commands/hash/hkeys.mdx +++ b/redis/sdks/py/commands/hash/hkeys.mdx @@ -24,6 +24,5 @@ redis.hset("myhash", values={ }) assert redis.hkeys("myhash") == ["field1", "field2"] - ``` diff --git a/redis/sdks/py/commands/hash/hpersist.mdx b/redis/sdks/py/commands/hash/hpersist.mdx new file mode 100644 index 00000000..c8b8aa79 --- /dev/null +++ b/redis/sdks/py/commands/hash/hpersist.mdx @@ -0,0 +1,35 @@ +--- +title: HPERSIST +description: Remove the expiration from one or more hash fields. +--- + +## Arguments + + + The key of the hash. + + + + The field or list of fields within the hash to remove the expiry from. + + +## Response + + + 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). + + + +```py Example +redis.hset(hash_name, field, value) +redis.hpexpire(hash_name, field, 1000) + +assert redis.hpersist(hash_name, field) == [1] +``` + diff --git a/redis/sdks/py/commands/hash/hpexpire.mdx b/redis/sdks/py/commands/hash/hpexpire.mdx new file mode 100644 index 00000000..45976c0d --- /dev/null +++ b/redis/sdks/py/commands/hash/hpexpire.mdx @@ -0,0 +1,55 @@ +--- +title: HPEXPIRE +description: Set a timeout on a hash field in milliseconds. +--- + +## Arguments + + + The key of the hash. + + + + The field or list of fields within the hash to set the expiry for. + + + + The timeout in milliseconds as an integer or a `datetime.timedelta` object. + + + + Set expiry only when the field has no expiry. Defaults to `False`. + + + + Set expiry only when the field has an existing expiry. Defaults to `False`. + + + + Set expiry only when the new expiry is greater than the current one. Defaults to `False`. + + + + Set expiry only when the new expiry is less than the current one. Defaults to `False`. + + +## Response + + + 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). + + + +```py Example +redis.hset(hash_name, field, value) + +assert redis.hpexpire(hash_name, field, 1000) == [1] +``` + diff --git a/redis/sdks/py/commands/hash/hpexpireat.mdx b/redis/sdks/py/commands/hash/hpexpireat.mdx new file mode 100644 index 00000000..ed3f3d47 --- /dev/null +++ b/redis/sdks/py/commands/hash/hpexpireat.mdx @@ -0,0 +1,55 @@ +--- +title: HPEXPIREAT +description: Sets an expiration time for field(s) in a hash in milliseconds since the Unix epoch. +--- + +## Arguments + + + The key of the hash. + + + + The field or list of fields to set an expiration time for. + + + + The expiration time as a Unix timestamp in milliseconds. + + + + Set expiry only when the field has no expiry. Defaults to `False`. + + + + Set expiry only when the field has an existing expiry. Defaults to `False`. + + + + Set expiry only when the new expiry is greater than the current one. Defaults to `False`. + + + + Set expiry only when the new expiry is less than the current one. Defaults to `False`. + + +## Response + + + 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). + + + +```py Example +redis.hset(hash_name, field, value) + +assert redis.hpexpireat(hash_name, field, int(time.time() * 1000) + 1000) == [1] +``` + diff --git a/redis/sdks/py/commands/hash/hpexpiretime.mdx b/redis/sdks/py/commands/hash/hpexpiretime.mdx new file mode 100644 index 00000000..87c23666 --- /dev/null +++ b/redis/sdks/py/commands/hash/hpexpiretime.mdx @@ -0,0 +1,34 @@ +--- +title: HPEXPIRETIME +description: Retrieves the expiration time of a field in a hash in milliseconds. +--- + +## Arguments + + + The key of the hash. + + + + The field or list of fields to retrieve the expiration time for. + + +## Response + + + 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). + + + +```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] +``` + diff --git a/redis/sdks/py/commands/hash/hpttl.mdx b/redis/sdks/py/commands/hash/hpttl.mdx new file mode 100644 index 00000000..3e1f0378 --- /dev/null +++ b/redis/sdks/py/commands/hash/hpttl.mdx @@ -0,0 +1,34 @@ +--- +title: HPTTL +description: Retrieves the remaining time-to-live (TTL) for field(s) in a hash in milliseconds. +--- + +## Arguments + + + The key of the hash. + + + + The field or list of fields to retrieve the TTL for. + + +## Response + + + A list of integers representing the remaining TTL in milliseconds 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. + + For more details, see [HPTTL documentation](https://redis.io/commands/hpttl). + + + +```py Example +redis.hset(hash_name, field, value) +redis.hpexpire(hash_name, field, 1000) + +assert redis.hpttl(hash_name, field) == [950] +``` + diff --git a/redis/sdks/py/commands/hash/httl.mdx b/redis/sdks/py/commands/hash/httl.mdx new file mode 100644 index 00000000..f8348d0b --- /dev/null +++ b/redis/sdks/py/commands/hash/httl.mdx @@ -0,0 +1,34 @@ +--- +title: HTTL +description: Retrieves the remaining time-to-live (TTL) for field(s) in a hash in seconds. +--- + +## Arguments + + + The key of the hash. + + + + The field or list of fields to retrieve the TTL for. + + +## Response + + + A list of integers representing the remaining TTL in seconds 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. + + For more details, see [HTTL documentation](https://redis.io/commands/httl). + + + +```py Example +redis.hset(hash_name, field, value) +redis.hexpire(hash_name, field, 10) + +assert redis.httl(hash_name, field) == [9] +``` + diff --git a/redis/sdks/py/commands/overview.mdx b/redis/sdks/py/commands/overview.mdx index 3cdbdea4..8d73a3f3 100644 --- a/redis/sdks/py/commands/overview.mdx +++ b/redis/sdks/py/commands/overview.mdx @@ -109,6 +109,15 @@ description: Available Commands in upstash-redis + + + + + + + + + @@ -133,6 +142,21 @@ description: Available Commands in upstash-redis + + + + + + + + + + + + + + + @@ -148,9 +172,12 @@ description: Available Commands in upstash-redis + + + - + diff --git a/redis/sdks/ts/commands/hash/hexists.mdx b/redis/sdks/ts/commands/hash/hexists.mdx index 3238012c..1992b35f 100644 --- a/redis/sdks/ts/commands/hash/hexists.mdx +++ b/redis/sdks/ts/commands/hash/hexists.mdx @@ -24,7 +24,7 @@ description: Checks if a field exists in a hash. ```ts Example await redis.hset("key", "field", "value"); const exists = await redis.hexists("key", "field"); -console.log(exists); // 1 +console.log(exists); // 1 ``` \ No newline at end of file diff --git a/redis/sdks/ts/commands/hash/hexpire.mdx b/redis/sdks/ts/commands/hash/hexpire.mdx new file mode 100644 index 00000000..951c8c77 --- /dev/null +++ b/redis/sdks/ts/commands/hash/hexpire.mdx @@ -0,0 +1,49 @@ +--- +title: HEXPIRE +description: Sets an expiration time for one or more fields in a hash. +--- + +## Arguments + + + The key of the hash. + + + + The field or fields to set an expiration time for. + + + + The time-to-live (TTL) in seconds. + + + + Optional condition for setting the expiration: + - `NX`: Set the expiration only if the field does not already have an expiration. + - `XX`: Set the expiration only if the field already has an expiration. + - `GT`: Set the expiration only if the new TTL is greater than the current TTL. + - `LT`: Set the expiration only if the new TTL is less than the current TTL. + + +## Response + + + 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). + + + + +```ts Example +await redis.hset("my-key", "my-field", "my-value"); +const expirationSet = await redis.hexpire("my-key", "my-field", 1); + +console.log(expirationSet); // 1 +``` + \ No newline at end of file diff --git a/redis/sdks/ts/commands/hash/hexpireat.mdx b/redis/sdks/ts/commands/hash/hexpireat.mdx new file mode 100644 index 00000000..68596709 --- /dev/null +++ b/redis/sdks/ts/commands/hash/hexpireat.mdx @@ -0,0 +1,48 @@ +--- +title: HEXPIREAT +description: Sets an expiration time for field(s) in a hash in seconds since the Unix epoch. +--- + +## Arguments + + + The key of the hash. + + + + The field(s) to set an expiration time for. + + + + The expiration time as a Unix timestamp in seconds. + + + + Optional condition for setting the expiration: + - `NX`: Set the expiration only if the field does not already have an expiration. + - `XX`: Set the expiration only if the field already has an expiration. + - `GT`: Set the expiration only if the new TTL is greater than the current TTL. + - `LT`: Set the expiration only if the new TTL is less than the current TTL. + + +## Response + + + 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 [HEXPIREAT documentation](https://redis.io/commands/hexpireat). + + + +```ts Example +await redis.hset("my-key", "my-field", "my-value"); +const expirationSet = await redis.hexpireat("my-key", "my-field", Math.floor(Date.now() / 1000) + 10); + +console.log(expirationSet); // [1] +``` + diff --git a/redis/sdks/ts/commands/hash/hexpiretime.mdx b/redis/sdks/ts/commands/hash/hexpiretime.mdx new file mode 100644 index 00000000..0dc7f177 --- /dev/null +++ b/redis/sdks/ts/commands/hash/hexpiretime.mdx @@ -0,0 +1,35 @@ +--- +title: HEXPIRETIME +description: Retrieves the expiration time of field(s) in a hash in seconds. +--- + +## Arguments + + + The key of the hash. + + + + The field(s) to retrieve the expiration time for. + + +## Response + + + The expiration time in seconds since the Unix epoch 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. + + For more details, see [HEXPIRETIME documentation](https://redis.io/commands/hexpiretime). + + + +```ts Example +await redis.hset("my-key", "my-field", "my-value"); +await redis.hexpireat("my-key", "my-field", Math.floor(Date.now() / 1000) + 10); +const expireTime = await redis.hexpiretime("my-key", "my-field"); + +console.log(expireTime); // e.g., [1697059200] +``` + diff --git a/redis/sdks/ts/commands/hash/hpersist.mdx b/redis/sdks/ts/commands/hash/hpersist.mdx new file mode 100644 index 00000000..e45def64 --- /dev/null +++ b/redis/sdks/ts/commands/hash/hpersist.mdx @@ -0,0 +1,37 @@ +--- +title: HPERSIST +description: Remove the expiration from one or more fields in a hash. +--- + +## Arguments + + + The key of the hash. + + + + The field or fields to remove the expiration from. + + +## Response + + + 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). + + + +```ts Example +await redis.hset("my-key", "my-field", "my-value"); +await redis.hpexpire("my-key", "my-field", 1000); + +const expirationRemoved = await redis.hpersist("my-key", "my-field"); + +console.log(expirationRemoved); // [1] +``` + diff --git a/redis/sdks/ts/commands/hash/hpexpire.mdx b/redis/sdks/ts/commands/hash/hpexpire.mdx new file mode 100644 index 00000000..a17708f8 --- /dev/null +++ b/redis/sdks/ts/commands/hash/hpexpire.mdx @@ -0,0 +1,50 @@ +--- +title: HPEXPIRE +description: Sets an expiration time for a field in a hash in milliseconds. +--- + +## Arguments + + + The key of the hash. + + + + The field or list of fields within the hash to set the expiry for. + + + + The time-to-live (TTL) in milliseconds. + + + + Optional condition for setting the expiration: + - `NX`: Set the expiration only if the field does not already have an expiration. + - `XX`: Set the expiration only if the field already has an expiration. + - `GT`: Set the expiration only if the new TTL is greater than the current TTL. + - `LT`: Set the expiration only if the new TTL is less than the current TTL. + + For more details, see [HPEXPIRE documentation](https://redis.io/commands/hpexpire). + + +## Response + + + 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). + + + +```ts Example +await redis.hset("my-key", "my-field", "my-value"); +const expirationSet = await redis.hpexpire("my-key", "my-field", 1000); + +console.log(expirationSet); // [1] +``` + diff --git a/redis/sdks/ts/commands/hash/hpexpireat.mdx b/redis/sdks/ts/commands/hash/hpexpireat.mdx new file mode 100644 index 00000000..c20742e0 --- /dev/null +++ b/redis/sdks/ts/commands/hash/hpexpireat.mdx @@ -0,0 +1,48 @@ +--- +title: HPEXPIREAT +description: Sets an expiration time for field(s) in a hash in milliseconds since the Unix epoch. +--- + +## Arguments + + + The key of the hash. + + + + The field(s) to set an expiration time for. + + + + The expiration time as a Unix timestamp in milliseconds. + + + + Optional condition for setting the expiration: + - `NX`: Set the expiration only if the field does not already have an expiration. + - `XX`: Set the expiration only if the field already has an expiration. + - `GT`: Set the expiration only if the new TTL is greater than the current TTL. + - `LT`: Set the expiration only if the new TTL is less than the current TTL. + + +## Response + + + 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 [HPEXPIREAT documentation](https://redis.io/commands/hpexpireat). + + + +```ts Example +await redis.hset("my-key", "my-field", "my-value"); +const expirationSet = await redis.hpexpireat("my-key", "my-field", Date.now() + 1000); + +console.log(expirationSet); // [1] +``` + diff --git a/redis/sdks/ts/commands/hash/hpexpiretime.mdx b/redis/sdks/ts/commands/hash/hpexpiretime.mdx new file mode 100644 index 00000000..f0eac2b7 --- /dev/null +++ b/redis/sdks/ts/commands/hash/hpexpiretime.mdx @@ -0,0 +1,35 @@ +--- +title: HPEXPIRETIME +description: Retrieves the expiration time of a field in a hash in milliseconds. +--- + +## Arguments + + + The key of the hash. + + + + The field(s) to retrieve the expiration time for. + + +## Response + + + 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). + + + +```ts Example +await redis.hset("my-key", "my-field", "my-value"); +await redis.hpexpireat("my-key", "my-field", Date.now() + 1000); +const expireTime = await redis.hpexpiretime("my-key", "my-field"); + +console.log(expireTime); // e.g., 1697059200000 +``` + diff --git a/redis/sdks/ts/commands/hash/hpttl.mdx b/redis/sdks/ts/commands/hash/hpttl.mdx new file mode 100644 index 00000000..3516cb01 --- /dev/null +++ b/redis/sdks/ts/commands/hash/hpttl.mdx @@ -0,0 +1,35 @@ +--- +title: HPTTL +description: Retrieves the remaining time-to-live (TTL) for field(s) in a hash in milliseconds. +--- + +## Arguments + + + The key of the hash. + + + + The field(s) to retrieve the TTL for. + + +## Response + + + The remaining TTL in milliseconds 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. + + For more details, see [HPTTL documentation](https://redis.io/commands/hpttl). + + + +```ts Example +await redis.hset("my-key", "my-field", "my-value"); +await redis.hpexpire("my-key", "my-field", 1000); +const ttl = await redis.hpttl("my-key", "my-field"); + +console.log(ttl); // e.g., [950] +``` + diff --git a/redis/sdks/ts/commands/hash/httl.mdx b/redis/sdks/ts/commands/hash/httl.mdx new file mode 100644 index 00000000..39e762b8 --- /dev/null +++ b/redis/sdks/ts/commands/hash/httl.mdx @@ -0,0 +1,35 @@ +--- +title: HTTL +description: Retrieves the remaining time-to-live (TTL) for field(s) in a hash in seconds. +--- + +## Arguments + + + The key of the hash. + + + + The field(s) to retrieve the TTL for. + + +## Response + + + The remaining TTL in seconds 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. + + For more details, see [HTTL documentation](https://redis.io/commands/httl). + + + +```ts Example +await redis.hset("my-key", "my-field", "my-value"); +await redis.hexpire("my-key", "my-field", 10); +const ttl = await redis.httl("my-key", "my-field"); + +console.log(ttl); // e.g., [9] +``` + diff --git a/redis/sdks/ts/commands/overview.mdx b/redis/sdks/ts/commands/overview.mdx index 8f6f8272..95d3ac40 100644 --- a/redis/sdks/ts/commands/overview.mdx +++ b/redis/sdks/ts/commands/overview.mdx @@ -106,6 +106,15 @@ description: Available Commands in @upstash/redis + + + + + + + + + @@ -127,6 +136,21 @@ description: Available Commands in @upstash/redis + + + + + + + + + + + + + + + @@ -142,6 +166,9 @@ description: Available Commands in @upstash/redis + + +