Skip to content

Commit c5c94a3

Browse files
Merge pull request #69 from RedisInsight/main
Releasing HFE tutorial
2 parents 3aff05c + 2824abf commit c5c94a3

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/ds/hashes.md

+35
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,39 @@ HINCRBY bike:1 price 100
4444
HINCRBY bike:1 price -100
4545
```
4646

47+
New in [Redis Community Edition version 7.4](https://hub.docker.com/layers/redis/redis-stack/7.4.0-v0/images/sha256-3e3c86603a81712d1311bc619ad124de15b2dca2b50722f23a4502b4d4054ba8) is the ability set the expiration time or the remaining time-to-live (TTL) for individual hash fields. This is called hash field expiration (HFE). HFE works just like [key expiration](https://redis.io/docs/latest/develop/use/keyspace/?utm_source=redisinsight&utm_medium=main&utm_campaign=tutorials#key-expiration) and includes the following commands:
48+
49+
- `hexpire` - set an expiration (time-to-live or TTL) in seconds on a hash key's field(s).
50+
- `hexpireat` - set a TTL as an absolute Unix timestamp (seconds since Unix epoch) on a hash key's field(s).
51+
- `hexpiretime` - returns the absolute Unix timestamp (seconds since Unix epoch) at which the hash key's field(s) will expire.
52+
- `hpersist` - remove expirations from a hash key's field(s).
53+
- `hpexpire` - set an expiration (time-to-live or TTL) in milliseconds on a hash key's field(s).
54+
- `hpexpireat` - set a TTL as an absolute Unix timestamp (milliseconds since Unix epoch) on a hash key's field(s).
55+
- `hpexpiretime` - returns the absolute Unix timestamp (milliseconds since Unix epoch) at which the the hash key's field(s) will expire.
56+
- `hpttl` - returns the remaining TTL in milliseconds of a hash key's field(s).
57+
- `httl` - returns the remaining TTL in seconds of a hash key's field(s).
58+
59+
```redis HFE example 1
60+
HSET hash field1 "foo" field2 "bar" field3 "baz"
61+
HEXPIRE hash 10 FIELDS 1 field2
62+
HTTL hash FIELDS 1 field2
63+
```
64+
65+
```redis HFE example 1 cont'd
66+
HTTL hash FIELDS 1 field2
67+
HGETALL hash
68+
```
69+
70+
```redis HFE example 2
71+
HSET hash field1 "foo" field2 "bar" field3 "baz"
72+
HEXPIRE hash 10 FIELDS 2 field1 field3
73+
HTTL hash FIELDS 2 field1 field3
74+
HPERSIST hash FIELDS 1 field3
75+
HTTL hash FIELDS 2 field1 field3
76+
```
77+
78+
```redis HFE example 2 cont'd
79+
HGETALL hash
80+
```
81+
4782
See [here](https://redis.io/docs/data-types/hashes?utm_source=redisinsight&utm_medium=main&utm_campaign=tutorials) for the hash type reference page, and [here](https://redis.io/commands/?group=hash?utm_source=redisinsight&utm_medium=main&utm_campaign=tutorials) for the entire set of Redis hash commands.

0 commit comments

Comments
 (0)