Generational cache does not reset the TTL
Closed this issue · 3 comments
For example, we have been using cache_method and setting the TTL to the default time - 24 hours. But we also have some background jobs that run something like:
object.cache_method_clear(:field)
object.send(field)
in order to refresh the object cache before it expires - so that we can keep the cache fresh and no one notices any delay.
But the generational cache does not reset the TTL. So, even though we are cleaning the field cache and setting it again it does not reset the TTL and the cached value will expire in less than TTL time - in fact, the TTL will keep counting since the first time that field was cached for that object no matter if we clean and set it again.
I would expect something to reset the cache here:
https://github.com/seamusabshere/cache_method/blob/master/lib/cache_method/generation.rb#L42-L47
Since we are using redis it would be calling EXPIRE with the key and the TTL time to reset it. but since cache method also supports memcached, I'm not really sure how to fix it. It seems it needs a layer of abstraction over the supported caching system.
Thoughts?
regarding the abstraction layer I just notice it is using https://github.com/seamusabshere/cache
@rubemz can you give me a (pseudocode) example?
@seamusabshere actually I can't duplicate it :p and I bet I was looking the ttl for the old cache entry. My bad then 👍 Sorry. closing this issue.