question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

calling SET removes the TTL of a record

See original GitHub issue

I am not sure if this is intentional, if there is a way to change it but the document of ioredis just sucks or is something not really possible with this module.

I created some record like

await client.setex('key1', 'hello', 10);
const x = await client.ttl('key1')
// x = 10

when the code is changed to the following

await client.setex('key1', 'hello', 10);
await client.set('key1', 'world');
const x = await client.ttl('key1')
// x = -1

just running a set command automatically removes TTL. Now I have tried looking at the types (d.ts) file for anything that I can use and there appears to be something called an “expiryMode” parameter in the set command. looking at possible values for this and wow… ioredis docs denies its existence. It has no default and enumerated values, not even docummented. so what is that for? what I am doing btw is try to update the record without altering the existing TTL value

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
adonisv79commented, Apr 5, 2020

ugh! nevermind! you guys should use enums for this on your Typescript…

EX seconds – Set the specified expire time, in seconds. PX milliseconds – Set the specified expire time, in milliseconds. NX – Only set the key if it does not already exist. XX – Only set the key if it already exist. KEEPTTL – Retain the time to live associated with the key

0reactions
adonisv79commented, Apr 5, 2020

ah got it! thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is DNS TTL + Best Practices - Varonis
DNS TTL (time to live) is a setting that tells the DNS resolver how long to cache a query before requesting a new...
Read more >
What is TTL? - ClouDNS
TTL for NXDOMAIN responses is set from the minimum of the MINIMUM field of the SOA record and the TTL of the SOA...
Read more >
How can I update a redis value without affecting the remaining ...
According to Redis documentation, the SET command removes the TTL because the key is overwritten. However you can use the EVAL command to ......
Read more >
Cassandra TTL intricacies and usage by examples - Medium
It would delete the record after set time after the value in that field. So obviously that field should be of type date...
Read more >
What Is The Lowest TTL I Can Get Away With? - NS1
While there is a sort of unspoken belief that setting a low TTL for a record will result in users getting sent to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found