Does Redis reset expiration time - node.js

I am using client.setex() to create a Redis cache with an expiration time of say 3600 seconds but I also update it from time to time, and for that I am using client.set().
Wondering if the expiration time stays the same or gets extended by 3600 every time I update that cache.

set() will remove the existing expiration time in Redis .
you can use :
client.set(key,value, "EX", client.ttl(key))
for continuing the expiration time.
for more detail :
https://stackoverflow.com/a/21897851/5677187

Related

Does a TTL get triggered from the time the record is created or at a certain interval like a cron job?

I just wanted to get a basic understanding of how TTLs work from the stand point of when exactly the record will refresh. Say I create a DNS record with a TTL of 1800 at 09:05 UTC, does that mean it will refresh at 09:35 UTC or 09:30 UTC?
This behaviour is important for me to understand as if it is the latter (where the record gets refreshed at 1800 second intervals - so every half an hour), then I can time my DNS record updates so that they are within a couple of minutes of refresh time so as to limit the amount of time the request points to the old address.
Any assistance on this is much appreciated.
https://www.varonis.com/blog/dns-ttl/
DNS TTL (time to live) represents the time each step takes for DNS to
cache a record. The TTL is like a stopwatch for how long to keep a DNS
record.
In other words, a DNS record with a TTL of 1800 (30 minutes) will "live" for 30 minutes ... from the time it is received by the caching server.
From the same link:
How Long Will it Take My DNS to Update? To honestly know that everyone
is seeing an updated DNS record, it is essential to calculate how long
it will “actually” take to propagate across DNS. This is accomplished
by using the following formula
TTL X (number of steps) = Fully propagated
For example, if your set TTL is 1800 seconds and there are five steps
(not counting the authoritative server), then your fully propagated
time would be 9000 seconds or no longer than 2 hours and 30 minutes.

Is there limit to the ttl param of the google calendar watch api?

I've been working on google calendar sync in node js. I want the notification channel for watching the events to be active forever, but I found that the time to live parameter is defaulted to 3600 seconds. Is there a limit to the value I can give as the time to live? The idea is to give a high enough value so that the channel lives practically for ever. Will this work? Or is it better to refresh these channels now and then?
Thanks in advance :) .
The maximum time is 2592000 seconds, or in other words 30 days.
This is not defined in the documentation, but if you try to set ttl to 50 years, or 60 days, it will set the expiration to 30 days from the point you created the notification channel.
Side-note: default is 604800 (at least this year)

Making node check files in a second plan

I'm trying to make a expire key system with nodejs to one app and for check expiration (30 days) I decided use a while loop and checking it, but as I thought, I need another thread to do this, I tried use the worker_thread but gives me "Module did not self-register" at "node_modules\Canvas\lib\bindings.js:3:18". There is a way to do this process or still another way to do the keys expire? I'm new to node and I don't have any other ideia.
Obs:. to check if a key is expired, it store the time in millis that the key was got and store another value with the time in millis 30 days after, and do a simple (expireTime - gotTime <= 0)

Create expired time, or countdown timer

How do I make the time expired, suppose I made an article, to be able to make it again, had to wait for 15 hours, I was using nodejs and node-datetime.
I think the current time plus 15 hours, but how?
thanks before
I suppose you have a database with the articles, so, just save the creation date in each article, and when a user requests the access to create a new article, verify if his last article is more than 15 hours old

invalid expire time in SETEX, sPort: 12702 in Redis

I am getting error while using Redis cache time=0. Same time using with Redis cache time=1, it is working as expected.
How to set Redis cache time value is 0. Please help
ErrorMessage
"Message":"An error has occurred.","ExceptionMessage":"invalid expire time in SETEX, sPort: 12702, LastCommand: ","ExceptionType":"ServiceStack.Redis.RedisResponseException"
I want set 0 as expire time, why because i am using dynamic page and it has many chunk. The Redis cache time coming from config file. Example: Chunk 1 with redis cache time of 2 minute. In particular time i dont want redis cache, that time i go and change 0 as redis cache time in configuration file.
In particular time i dont want redis cache, that time i go and change 0 as redis cache time in configuration file.
It seems that you don't want to store a key by commanding redis to store a key. Which is very inconvenient.
If you don't want to change your application code than you could save it just for 1 sec, which is minimal. As setex command expect the time is positive means greater than zero.
Otherwise, you can tweak your code by ignoring to store in cache while ttl is zero. Or you can save it for 1 milisecond in redis using psetex insted of setex.

Resources