From 401cc5f68a1d50ab6539be75400d2871b416e0f5 Mon Sep 17 00:00:00 2001 From: Lior Kogan Date: Tue, 21 Oct 2025 20:08:50 +0300 Subject: [PATCH 1/2] Update hash field expiration details for Redis 8.0 Added new commands HGETEX and HSETEX for setting expiration on hash fields. --- content/develop/data-types/hashes.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/content/develop/data-types/hashes.md b/content/develop/data-types/hashes.md index 3f109ae6a6..efc2a4fba7 100644 --- a/content/develop/data-types/hashes.md +++ b/content/develop/data-types/hashes.md @@ -100,7 +100,7 @@ See the [complete list of hash commands]({{< relref "/commands/" >}}?group=hash) ## Field expiration -New in Redis Open Source 7.4 is the ability to specify an expiration time or a time-to-live (TTL) value for individual hash fields. +In Redis 7.4 we introduced the ability to specify an expiration time or a time-to-live (TTL) value for individual hash fields. This capability is comparable to [key expiration]({{< relref "/develop/using-commands/keyspace#key-expiration" >}}) and includes a number of similar commands. Use the following commands to set either an exact expiration time or a TTL value for specific fields: @@ -123,6 +123,11 @@ Use the following command to remove the expiration of specific fields: * [`HPERSIST`]({{< relref "/commands/hpersist" >}}): remove the expiration. +In Redis 8.0 we introduced the following commands: + +* [`HGETEX`]({{< relref "/commands/HGETEX" >}}): Get the value of one or more fields of a given hash key and optionally set their expiration time or time-to-live (TTL). +* [`HSETEX`]({{< relref "/commands/HSETEX" >}}): Set the value of one or more fields of a given hash key and optionally set their expiration time or time-to-live (TTL). + ### Common field expiration use cases 1. **Event Tracking**: Use a hash key to store events from the last hour. Set each event's TTL to one hour. Use `HLEN` to count events from the past hour. @@ -201,4 +206,4 @@ In practice, your hashes are limited only by the overall memory on the VMs hosti ## Learn more * [Redis Hashes Explained](https://www.youtube.com/watch?v=-KdITaRkQ-U) is a short, comprehensive video explainer covering Redis hashes. -* [Redis University's RU101](https://university.redis.com/courses/ru101/) covers Redis hashes in detail. \ No newline at end of file +* [Redis University's RU101](https://university.redis.com/courses/ru101/) covers Redis hashes in detail. From 638698e3aacc3f02063196b70d6731dfcafca4f5 Mon Sep 17 00:00:00 2001 From: David Dougherty Date: Mon, 27 Oct 2025 08:18:48 -0700 Subject: [PATCH 2/2] Apply suggestions from code review Update to adhere to our style guide. --- content/develop/data-types/hashes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/develop/data-types/hashes.md b/content/develop/data-types/hashes.md index efc2a4fba7..0a684db95a 100644 --- a/content/develop/data-types/hashes.md +++ b/content/develop/data-types/hashes.md @@ -100,7 +100,7 @@ See the [complete list of hash commands]({{< relref "/commands/" >}}?group=hash) ## Field expiration -In Redis 7.4 we introduced the ability to specify an expiration time or a time-to-live (TTL) value for individual hash fields. +Redis 7.4 introduced the ability to specify an expiration time or a time-to-live (TTL) value for individual hash fields. This capability is comparable to [key expiration]({{< relref "/develop/using-commands/keyspace#key-expiration" >}}) and includes a number of similar commands. Use the following commands to set either an exact expiration time or a TTL value for specific fields: @@ -123,7 +123,7 @@ Use the following command to remove the expiration of specific fields: * [`HPERSIST`]({{< relref "/commands/hpersist" >}}): remove the expiration. -In Redis 8.0 we introduced the following commands: +Redis 8.0 introduced the following commands: * [`HGETEX`]({{< relref "/commands/HGETEX" >}}): Get the value of one or more fields of a given hash key and optionally set their expiration time or time-to-live (TTL). * [`HSETEX`]({{< relref "/commands/HSETEX" >}}): Set the value of one or more fields of a given hash key and optionally set their expiration time or time-to-live (TTL).