Skip to content

Commit 57a5902

Browse files
authored
docs(example): add better httl examples
1 parent 6ecd555 commit 57a5902

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

examples/ttl.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ async function main() {
2626
await redis.persist("foo"); // Remove the existing timeout on key "foo"
2727
console.log(await redis.ttl("foo")); // -1
2828

29-
await redis.hset("foo", "bar", "foobar");
30-
await redis.hexpire("foo", 10, "FIELDS", 1, "bar"); // Add TTL to hset field
29+
await redis.hset("hfoo", "hbar", "hfoobar");
30+
// hexpire is available since Redis 7.4.0
31+
await redis.hexpire("hfoo", 20, "FIELDS", 1, "hbar"); // Add TTL to hset field
32+
console.log(await redis.call("httl", "hfoo", "FIELDS", "1", "hbar")); // [ 20 ]
33+
34+
await redis.hpexpire("hfoo", 10000, "FIELDS", 1, "hbar");
35+
console.log(await redis.call("httl", "hfoo", "FIELDS", "1", "hbar")); // [ 10 ]
3136
}
3237

3338
main();

0 commit comments

Comments
 (0)