Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions content/develop/data-types/hashes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand Down Expand Up @@ -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.
* [Redis University's RU101](https://university.redis.com/courses/ru101/) covers Redis hashes in detail.