1

some keys do not have expiration date. Best way I can think of is to use "get *" (but there are millions of keys), store that and then use the TTL to see if has an expiry. If it doesn't then you set it.

Would this be the way to go?

I see a similar question here, that's not a unix command. How would I implement this in unix or maybe C#(I am using SSH Nuget package)?

dqv70219
  • 37
  • 8
  • To be clear, you want a language specific way to get at the details you get from TTL? https://redis.io/commands/ttl Maybe this: https://github.com/caquino/redis-bash –  Mar 06 '18 at 19:41
  • @jdv Yes, in C#. I thought you could do it in unix by the link I posted, but I think that's python. Looking at the github link you provide, the command - "redis-cli keys "*" | while read LINE ; do TTL=`redis-cli ttl "$LINE"`; if [ $TTL -eq -1 ]; then echo "$LINE"; fi; done" will work on there? – dqv70219 Mar 06 '18 at 21:24
  • You should [edit] your question and make it clear what you want to do, what you have tried, and what results you got. –  Mar 07 '18 at 15:09

1 Answers1

0

2 ways to do that:

  1. through the redis database notification, you can know the op on redis key, and by subscribe those messages, you can run ttl on those keys.
  2. run a task that scan the redis key set and run ttl on them.

The main idea is that do it quick and dont block the redis.

herokingsley
  • 403
  • 3
  • 10
  • for #1, could you explain it in simpler terms? for #2, what do you mean by task? if I do something like "keys *", it would take forever and block calls. How would I keep track of the keys I have gone over and search a little bit at a time so I don't block other calls coming to Redis – dqv70219 Mar 07 '18 at 18:45