From c4e5bba5baf7ba3952857f1bc3d4d92b027e1b47 Mon Sep 17 00:00:00 2001 From: CahidArda Date: Thu, 3 Apr 2025 10:29:23 +0300 Subject: [PATCH 1/5] feat: add HEXPIRE docs to the redis SDKs --- mint.json | 2 + redis/sdks/py/commands/hash/hexpire.mdx | 55 +++++++++++++++++++++++++ redis/sdks/ts/commands/hash/hexists.mdx | 2 +- redis/sdks/ts/commands/hash/hexpire.mdx | 49 ++++++++++++++++++++++ 4 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 redis/sdks/py/commands/hash/hexpire.mdx create mode 100644 redis/sdks/ts/commands/hash/hexpire.mdx diff --git a/mint.json b/mint.json index ef1fee28..cd2a1018 100644 --- a/mint.json +++ b/mint.json @@ -236,6 +236,7 @@ "pages": [ "redis/sdks/ts/commands/hash/hdel", "redis/sdks/ts/commands/hash/hexists", + "redis/sdks/ts/commands/hash/hexpire", "redis/sdks/ts/commands/hash/hget", "redis/sdks/ts/commands/hash/hgetall", "redis/sdks/ts/commands/hash/hincrby", @@ -465,6 +466,7 @@ "pages": [ "redis/sdks/py/commands/hash/hdel", "redis/sdks/py/commands/hash/hexists", + "redis/sdks/py/commands/hash/hexpire", "redis/sdks/py/commands/hash/hget", "redis/sdks/py/commands/hash/hgetall", "redis/sdks/py/commands/hash/hincrby", diff --git a/redis/sdks/py/commands/hash/hexpire.mdx b/redis/sdks/py/commands/hash/hexpire.mdx new file mode 100644 index 00000000..3f3869b9 --- /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 the number of fields for which 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/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..fc81c1fa --- /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 the number of fields for which 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 From 8bb4855f88ba4d921992f0866218027910d1d881 Mon Sep 17 00:00:00 2001 From: CahidArda Date: Thu, 3 Apr 2025 15:08:16 +0300 Subject: [PATCH 2/5] fix: add hexpire to overviews --- redis/sdks/py/commands/overview.mdx | 3 +++ redis/sdks/ts/commands/overview.mdx | 3 +++ 2 files changed, 6 insertions(+) diff --git a/redis/sdks/py/commands/overview.mdx b/redis/sdks/py/commands/overview.mdx index 3cdbdea4..6857b56c 100644 --- a/redis/sdks/py/commands/overview.mdx +++ b/redis/sdks/py/commands/overview.mdx @@ -124,6 +124,9 @@ description: Available Commands in upstash-redis + + + diff --git a/redis/sdks/ts/commands/overview.mdx b/redis/sdks/ts/commands/overview.mdx index 8f6f8272..b0d44515 100644 --- a/redis/sdks/ts/commands/overview.mdx +++ b/redis/sdks/ts/commands/overview.mdx @@ -121,6 +121,9 @@ description: Available Commands in @upstash/redis + + + From 24a9dcff384c48d7abd03c92956a54a905b41a0c Mon Sep 17 00:00:00 2001 From: CahidArda Date: Tue, 8 Apr 2025 12:12:08 +0300 Subject: [PATCH 3/5] fix: add other hash commands --- mint.json | 16 ++++++ redis/sdks/py/commands/hash/hexpire.mdx | 2 +- redis/sdks/py/commands/hash/hexpireat.mdx | 52 ++++++++++++++++++ redis/sdks/py/commands/hash/hexpiretime.mdx | 32 ++++++++++++ redis/sdks/py/commands/hash/hpersist.mdx | 35 +++++++++++++ redis/sdks/py/commands/hash/hpexpire.mdx | 55 ++++++++++++++++++++ redis/sdks/py/commands/hash/hpexpireat.mdx | 52 ++++++++++++++++++ redis/sdks/py/commands/hash/hpexpiretime.mdx | 32 ++++++++++++ redis/sdks/py/commands/hash/hpttl.mdx | 32 ++++++++++++ redis/sdks/py/commands/hash/httl.mdx | 32 ++++++++++++ redis/sdks/py/commands/overview.mdx | 32 ++++++++++-- redis/sdks/ts/commands/hash/hexpire.mdx | 10 ++-- redis/sdks/ts/commands/hash/hexpireat.mdx | 48 +++++++++++++++++ redis/sdks/ts/commands/hash/hexpiretime.mdx | 33 ++++++++++++ redis/sdks/ts/commands/hash/hpersist.mdx | 37 +++++++++++++ redis/sdks/ts/commands/hash/hpexpire.mdx | 48 +++++++++++++++++ redis/sdks/ts/commands/hash/hpexpireat.mdx | 48 +++++++++++++++++ redis/sdks/ts/commands/hash/hpexpiretime.mdx | 33 ++++++++++++ redis/sdks/ts/commands/hash/hpttl.mdx | 33 ++++++++++++ redis/sdks/ts/commands/hash/httl.mdx | 33 ++++++++++++ redis/sdks/ts/commands/overview.mdx | 30 +++++++++-- 21 files changed, 712 insertions(+), 13 deletions(-) create mode 100644 redis/sdks/py/commands/hash/hexpireat.mdx create mode 100644 redis/sdks/py/commands/hash/hexpiretime.mdx create mode 100644 redis/sdks/py/commands/hash/hpersist.mdx create mode 100644 redis/sdks/py/commands/hash/hpexpire.mdx create mode 100644 redis/sdks/py/commands/hash/hpexpireat.mdx create mode 100644 redis/sdks/py/commands/hash/hpexpiretime.mdx create mode 100644 redis/sdks/py/commands/hash/hpttl.mdx create mode 100644 redis/sdks/py/commands/hash/httl.mdx create mode 100644 redis/sdks/ts/commands/hash/hexpireat.mdx create mode 100644 redis/sdks/ts/commands/hash/hexpiretime.mdx create mode 100644 redis/sdks/ts/commands/hash/hpersist.mdx create mode 100644 redis/sdks/ts/commands/hash/hpexpire.mdx create mode 100644 redis/sdks/ts/commands/hash/hpexpireat.mdx create mode 100644 redis/sdks/ts/commands/hash/hpexpiretime.mdx create mode 100644 redis/sdks/ts/commands/hash/hpttl.mdx create mode 100644 redis/sdks/ts/commands/hash/httl.mdx diff --git a/mint.json b/mint.json index cd2a1018..579b5254 100644 --- a/mint.json +++ b/mint.json @@ -237,6 +237,8 @@ "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", @@ -247,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/persist", + "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" ] }, @@ -467,6 +475,8 @@ "redis/sdks/py/commands/hash/hdel", "redis/sdks/py/commands/hash/hexists", "redis/sdks/py/commands/hash/hexpire", + "redis/sdks/ts/commands/hash/hexpireat", + "redis/sdks/ts/commands/hash/hexpiretime", "redis/sdks/py/commands/hash/hget", "redis/sdks/py/commands/hash/hgetall", "redis/sdks/py/commands/hash/hincrby", @@ -477,9 +487,15 @@ "redis/sdks/py/commands/hash/hrandfield", "redis/sdks/py/commands/hash/hscan", "redis/sdks/py/commands/hash/hset", + "redis/sdks/ts/commands/hash/persist", + "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/py/commands/hash/hmset", "redis/sdks/py/commands/hash/hsetnx", "redis/sdks/py/commands/hash/hstrlen", + "redis/sdks/ts/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 index 3f3869b9..ca7ea3ed 100644 --- a/redis/sdks/py/commands/hash/hexpire.mdx +++ b/redis/sdks/py/commands/hash/hexpire.mdx @@ -36,7 +36,7 @@ description: Set a timeout on a hash field in seconds. ## Response - A list of integers indicating the number of fields for which the expiry was successfully set. + 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. diff --git a/redis/sdks/py/commands/hash/hexpireat.mdx b/redis/sdks/py/commands/hash/hexpireat.mdx new file mode 100644 index 00000000..f794c577 --- /dev/null +++ b/redis/sdks/py/commands/hash/hexpireat.mdx @@ -0,0 +1,52 @@ +--- +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. + + + +```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..b60358ec --- /dev/null +++ b/redis/sdks/py/commands/hash/hexpiretime.mdx @@ -0,0 +1,32 @@ +--- +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. + + + +```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/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..88e14692 --- /dev/null +++ b/redis/sdks/py/commands/hash/hpexpireat.mdx @@ -0,0 +1,52 @@ +--- +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. + + + +```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..2e753b52 --- /dev/null +++ b/redis/sdks/py/commands/hash/hpexpiretime.mdx @@ -0,0 +1,32 @@ +--- +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. + + + +```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..7cdab67f --- /dev/null +++ b/redis/sdks/py/commands/hash/hpttl.mdx @@ -0,0 +1,32 @@ +--- +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. + + + +```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..8ce25bf0 --- /dev/null +++ b/redis/sdks/py/commands/hash/httl.mdx @@ -0,0 +1,32 @@ +--- +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. + + + +```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 6857b56c..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 + + + + + + + + + @@ -124,9 +133,6 @@ description: Available Commands in upstash-redis - - - @@ -136,6 +142,21 @@ description: Available Commands in upstash-redis + + + + + + + + + + + + + + + @@ -151,9 +172,12 @@ description: Available Commands in upstash-redis + + + - + diff --git a/redis/sdks/ts/commands/hash/hexpire.mdx b/redis/sdks/ts/commands/hash/hexpire.mdx index fc81c1fa..951c8c77 100644 --- a/redis/sdks/ts/commands/hash/hexpire.mdx +++ b/redis/sdks/ts/commands/hash/hexpire.mdx @@ -9,15 +9,15 @@ description: Sets an expiration time for one or more fields in a hash. 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. @@ -27,8 +27,8 @@ description: Sets an expiration time for one or more fields in a hash. ## Response - - A list of integers indicating the number of fields for which the expiry was successfully set. + + 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. 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..6402332f --- /dev/null +++ b/redis/sdks/ts/commands/hash/hexpiretime.mdx @@ -0,0 +1,33 @@ +--- +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. + + + +```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..db10440f --- /dev/null +++ b/redis/sdks/ts/commands/hash/hpexpire.mdx @@ -0,0 +1,48 @@ +--- +title: HPEXPIRE +description: Sets an expiration time for a field in a hash in milliseconds. +--- + +## Arguments + + + The key of the hash. + + + + The field(s) to set an expiration time 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. + + +## 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..c3c91ed8 --- /dev/null +++ b/redis/sdks/ts/commands/hash/hpexpiretime.mdx @@ -0,0 +1,33 @@ +--- +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. + + + +```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..d9e06b19 --- /dev/null +++ b/redis/sdks/ts/commands/hash/hpttl.mdx @@ -0,0 +1,33 @@ +--- +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. + + + +```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..cce10e88 --- /dev/null +++ b/redis/sdks/ts/commands/hash/httl.mdx @@ -0,0 +1,33 @@ +--- +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. + + + +```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 b0d44515..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 + + + + + + + + + @@ -121,15 +130,27 @@ description: Available Commands in @upstash/redis - - - + + + + + + + + + + + + + + + @@ -145,6 +166,9 @@ description: Available Commands in @upstash/redis + + + From 058710b4c2f6f61301829425bfea399a8876ab90 Mon Sep 17 00:00:00 2001 From: CahidArda Date: Fri, 11 Apr 2025 15:23:21 +0300 Subject: [PATCH 4/5] fix: review --- mint.json | 18 +++++++++--------- redis/sdks/py/commands/hash/hexpireat.mdx | 1 + redis/sdks/py/commands/hash/hkeys.mdx | 1 - redis/sdks/py/commands/hash/hpexpireat.mdx | 1 + redis/sdks/ts/commands/hash/hpexpire.mdx | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/mint.json b/mint.json index 579b5254..805a6070 100644 --- a/mint.json +++ b/mint.json @@ -249,7 +249,7 @@ "redis/sdks/ts/commands/hash/hrandfield", "redis/sdks/ts/commands/hash/hscan", "redis/sdks/ts/commands/hash/hset", - "redis/sdks/ts/commands/hash/persist", + "redis/sdks/ts/commands/hash/hpersist", "redis/sdks/ts/commands/hash/hpexpire", "redis/sdks/ts/commands/hash/hpexpireat", "redis/sdks/ts/commands/hash/hpexpiretime", @@ -475,8 +475,8 @@ "redis/sdks/py/commands/hash/hdel", "redis/sdks/py/commands/hash/hexists", "redis/sdks/py/commands/hash/hexpire", - "redis/sdks/ts/commands/hash/hexpireat", - "redis/sdks/ts/commands/hash/hexpiretime", + "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", @@ -487,15 +487,15 @@ "redis/sdks/py/commands/hash/hrandfield", "redis/sdks/py/commands/hash/hscan", "redis/sdks/py/commands/hash/hset", - "redis/sdks/ts/commands/hash/persist", - "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/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/ts/commands/hash/httl", + "redis/sdks/py/commands/hash/httl", "redis/sdks/py/commands/hash/hvals" ] }, diff --git a/redis/sdks/py/commands/hash/hexpireat.mdx b/redis/sdks/py/commands/hash/hexpireat.mdx index f794c577..eee1f125 100644 --- a/redis/sdks/py/commands/hash/hexpireat.mdx +++ b/redis/sdks/py/commands/hash/hexpireat.mdx @@ -47,6 +47,7 @@ description: Sets an expiration time for field(s) in a hash in seconds since the ```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/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/hpexpireat.mdx b/redis/sdks/py/commands/hash/hpexpireat.mdx index 88e14692..f8f48698 100644 --- a/redis/sdks/py/commands/hash/hpexpireat.mdx +++ b/redis/sdks/py/commands/hash/hpexpireat.mdx @@ -47,6 +47,7 @@ description: Sets an expiration time for field(s) in a hash in milliseconds sinc ```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/ts/commands/hash/hpexpire.mdx b/redis/sdks/ts/commands/hash/hpexpire.mdx index db10440f..ae087ed6 100644 --- a/redis/sdks/ts/commands/hash/hpexpire.mdx +++ b/redis/sdks/ts/commands/hash/hpexpire.mdx @@ -10,7 +10,7 @@ description: Sets an expiration time for a field in a hash in milliseconds. - The field(s) to set an expiration time for. + The field or list of fields within the hash to set the expiry for. From cfa0a12874d8ceebc854319ecc8d9c2eba7bc684 Mon Sep 17 00:00:00 2001 From: CahidArda Date: Fri, 11 Apr 2025 15:50:35 +0300 Subject: [PATCH 5/5] fix: add links to redis commands --- redis/sdks/py/commands/hash/hexpireat.mdx | 2 ++ redis/sdks/py/commands/hash/hexpiretime.mdx | 2 ++ redis/sdks/py/commands/hash/hpexpireat.mdx | 2 ++ redis/sdks/py/commands/hash/hpexpiretime.mdx | 2 ++ redis/sdks/py/commands/hash/hpttl.mdx | 2 ++ redis/sdks/py/commands/hash/httl.mdx | 2 ++ redis/sdks/ts/commands/hash/hexpiretime.mdx | 2 ++ redis/sdks/ts/commands/hash/hpexpire.mdx | 4 +++- redis/sdks/ts/commands/hash/hpexpiretime.mdx | 2 ++ redis/sdks/ts/commands/hash/hpttl.mdx | 2 ++ redis/sdks/ts/commands/hash/httl.mdx | 2 ++ 11 files changed, 23 insertions(+), 1 deletion(-) diff --git a/redis/sdks/py/commands/hash/hexpireat.mdx b/redis/sdks/py/commands/hash/hexpireat.mdx index eee1f125..8fb9d243 100644 --- a/redis/sdks/py/commands/hash/hexpireat.mdx +++ b/redis/sdks/py/commands/hash/hexpireat.mdx @@ -42,6 +42,8 @@ description: Sets an expiration time for field(s) in a hash in seconds since the - `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). diff --git a/redis/sdks/py/commands/hash/hexpiretime.mdx b/redis/sdks/py/commands/hash/hexpiretime.mdx index b60358ec..ac4242c3 100644 --- a/redis/sdks/py/commands/hash/hexpiretime.mdx +++ b/redis/sdks/py/commands/hash/hexpiretime.mdx @@ -20,6 +20,8 @@ description: Retrieves the expiration time of field(s) in a hash in seconds. - `-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). diff --git a/redis/sdks/py/commands/hash/hpexpireat.mdx b/redis/sdks/py/commands/hash/hpexpireat.mdx index f8f48698..ed3f3d47 100644 --- a/redis/sdks/py/commands/hash/hpexpireat.mdx +++ b/redis/sdks/py/commands/hash/hpexpireat.mdx @@ -42,6 +42,8 @@ description: Sets an expiration time for field(s) in a hash in milliseconds sinc - `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). diff --git a/redis/sdks/py/commands/hash/hpexpiretime.mdx b/redis/sdks/py/commands/hash/hpexpiretime.mdx index 2e753b52..87c23666 100644 --- a/redis/sdks/py/commands/hash/hpexpiretime.mdx +++ b/redis/sdks/py/commands/hash/hpexpiretime.mdx @@ -20,6 +20,8 @@ description: Retrieves the expiration time of a field in a hash in milliseconds. - `-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). diff --git a/redis/sdks/py/commands/hash/hpttl.mdx b/redis/sdks/py/commands/hash/hpttl.mdx index 7cdab67f..3e1f0378 100644 --- a/redis/sdks/py/commands/hash/hpttl.mdx +++ b/redis/sdks/py/commands/hash/hpttl.mdx @@ -20,6 +20,8 @@ description: Retrieves the remaining time-to-live (TTL) for field(s) in a hash i - `-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). diff --git a/redis/sdks/py/commands/hash/httl.mdx b/redis/sdks/py/commands/hash/httl.mdx index 8ce25bf0..f8348d0b 100644 --- a/redis/sdks/py/commands/hash/httl.mdx +++ b/redis/sdks/py/commands/hash/httl.mdx @@ -20,6 +20,8 @@ description: Retrieves the remaining time-to-live (TTL) for field(s) in a hash i - `-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). diff --git a/redis/sdks/ts/commands/hash/hexpiretime.mdx b/redis/sdks/ts/commands/hash/hexpiretime.mdx index 6402332f..0dc7f177 100644 --- a/redis/sdks/ts/commands/hash/hexpiretime.mdx +++ b/redis/sdks/ts/commands/hash/hexpiretime.mdx @@ -20,6 +20,8 @@ description: Retrieves the expiration time of field(s) in a hash in seconds. - `-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). diff --git a/redis/sdks/ts/commands/hash/hpexpire.mdx b/redis/sdks/ts/commands/hash/hpexpire.mdx index ae087ed6..a17708f8 100644 --- a/redis/sdks/ts/commands/hash/hpexpire.mdx +++ b/redis/sdks/ts/commands/hash/hpexpire.mdx @@ -9,7 +9,7 @@ description: Sets an expiration time for a field in a hash in milliseconds. The key of the hash. - + The field or list of fields within the hash to set the expiry for. @@ -23,6 +23,8 @@ description: Sets an expiration time for a field in a hash in milliseconds. - `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 diff --git a/redis/sdks/ts/commands/hash/hpexpiretime.mdx b/redis/sdks/ts/commands/hash/hpexpiretime.mdx index c3c91ed8..f0eac2b7 100644 --- a/redis/sdks/ts/commands/hash/hpexpiretime.mdx +++ b/redis/sdks/ts/commands/hash/hpexpiretime.mdx @@ -20,6 +20,8 @@ description: Retrieves the expiration time of a field in a hash in milliseconds. - `-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). diff --git a/redis/sdks/ts/commands/hash/hpttl.mdx b/redis/sdks/ts/commands/hash/hpttl.mdx index d9e06b19..3516cb01 100644 --- a/redis/sdks/ts/commands/hash/hpttl.mdx +++ b/redis/sdks/ts/commands/hash/hpttl.mdx @@ -20,6 +20,8 @@ description: Retrieves the remaining time-to-live (TTL) for field(s) in a hash i - `-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). diff --git a/redis/sdks/ts/commands/hash/httl.mdx b/redis/sdks/ts/commands/hash/httl.mdx index cce10e88..39e762b8 100644 --- a/redis/sdks/ts/commands/hash/httl.mdx +++ b/redis/sdks/ts/commands/hash/httl.mdx @@ -20,6 +20,8 @@ description: Retrieves the remaining time-to-live (TTL) for field(s) in a hash i - `-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).