I have a Sinatra app on Heroku and I fetch data from many 3rd party APIs and store it in memcache, to speed up load time.
But the data is not updating: the data that is loaded in the first time after enabling the plugin stays in the memcache all the time and it does not expire.
Here are parts of my code:
set :cache, Dalli:client.new
configure do
set :cache_default_expiry, 300
end
def get_apidata()
apidata = settings.cache.get('apidata')
if apidatadata.nil?
# getting data from API
settings.cache.set('apidata',apidata)
Where is problem in my code, why isn’t cached data expiring?
From my tests
set :cache_default_expirydoes not work. What you can do instead is this: