node-cache/node-cache

How to obtain TTL of the rest of the time

tangtang520 opened this issue · 5 comments

How to obtain TTL of the rest of the time

There is currently no option to retrieve the ttl of a key.

I added a method myCache.getTtl( key, [callback] ) to handle your need.
https://github.com/tcs-de/nodecache#get-ttl-getttl

when i try to get the TTL of an existing key my app just crash without any error. sync and async version.
when i try to get the TTL of an unknown key then i get an undefined like the doc says. what am i doing wrong?

@filly82 : can you provide me an example?
I tested the .getTtl() here: https://tonicdev.com/mpneuried/5718b7f13ffa30120097000f
Can you change the code, so i can reproduce your case.

of course i cannot reproduce it :(
this is basically what i am doing, but it works on that platform: https://tonicdev.com/5718bce2fab6891400f3d34c/5718c1e4a1e962110076c58e