#Does cache entry get deleted after TTL expires with @nestjs/cache-manager?

6 messages · Page 1 of 1 (latest)

vivid goblet
#

Or do I have to delete it after the TTL expired manually? If so, how?

quiet swift
vivid goblet
#

I'm using the built-in store

quiet swift
#

That would be the memory store, which uses lru-cache under the hood.
You could set https://github.com/isaacs/node-lru-cache#ttlautopurge to make sure keys are deleted once they expire, but it's probably not a good idea:

Note that this may significantly degrade performance, especially if the cache is storing a large number of items. It is almost always best to just leave the stale items in the cache, and let them fall out as new items are added.

Why do you care about deleting expired keys?

vivid goblet
#

I'm storing valid JWT in cahce to speed up responses after the first verification. It might lead to some trouble if I have old invalid entries flying around there.

quiet swift
#

With the default configuration, you won't get them back with .get() after the specified ttl.

They'll still be in the memory somewhere, but you won't get them using the standard methods.