0
在我的新Rails应用程序中,它是一个API消费者/客户端。我正在使用httParty来请求。我使用在这个岗位http://www.binpress.com/tutorial/ruby-tutorial-building-a-robust-json-api-client/140Redis:在httparty客户端中正确缓存来自API的响应,在api响应中将缓存中的缓存过期到期
def handle_caching(options)
if cached = $redis.get(cache_key(options))
eval(cached)
else
yield.tap do |results|
$redis.set(cache_key(options), results)
end
end
end
建议代码,但它永久缓存页面和页面时,有在API内容变化不被过期。如何正确地在API响应中对缓存头进行缓存。