Skip to content
Merged
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
8 changes: 8 additions & 0 deletions examples/ttl.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ async function main() {

await redis.persist("foo"); // Remove the existing timeout on key "foo"
console.log(await redis.ttl("foo")); // -1

await redis.hset("hfoo", "hbar", "hfoobar");
// hexpire is available since Redis 7.4.0
await redis.hexpire("hfoo", 20, "FIELDS", 1, "hbar"); // Add TTL to hset field
console.log(await redis.call("httl", "hfoo", "FIELDS", "1", "hbar")); // [ 20 ]

await redis.hpexpire("hfoo", 10 * 1000, "FIELDS", 1, "hbar"); // unit is millisecond for hpexpire
console.log(await redis.call("httl", "hfoo", "FIELDS", "1", "hbar")); // [ 10 ]
}

main();
Loading