Closed eyberg closed 10 years ago
I just ran into what I think must be the same issue using dalli on Heroku. In the meantime, I'm monkeypatching:
# config/initializers/api_cache_monkeypatch
class APICache
class DalliStore < APICache::AbstractStore
def expired?(key, timeout)
# If for some reason the created_at key isn't set, set it such that expired will be true :
@dalli.set("#{key}_created_at", Time.now + timeout + 1 ) if @dalli.get("#{key}_created_at").nil?
Time.now - @dalli.get("#{key}_created_at") > timeout
end
end
end
This is probably a horrible inefficient hack, but it seems to work. I'm a bit of a novice, so feel free to pick holes.
Sorry this got ignored for an eternity - in any case it's now fixed in 0.3.0. Cheers.
With both redis and memcached's default behavior of expiring keys when full, APICache sometimes throws exceptions when the key containing data is present but not the key w/the expiration date.
This patch simply ensures both keys are present when looking them up.
Two lookups doesn't seem ideal but is there a better solution for this behavior?