开发者

time-based expiration of cache in Rails?

开发者 https://www.devze.com 2023-04-02 04:10 出处:网络
Rails offers several layers of caching: page, action, and fragment. I was surprised that none of these methods offer a time-based expiration of the cache.

Rails offers several layers of caching: page, action, and fragment. I was surprised that none of these methods offer a time-based expiration of the cache.

I for example am showing a list of "top selling products", which is ranked by number of purchases, 开发者_如何学JAVAfor this listing it is good enough for us to refresh the cache once a day. We do not want to refresh the cache every time a purchase is made because that happens hundreds of times a day.

What is a good solution for this scenario?


http://guides.rubyonrails.org/caching_with_rails.html#configuration

Refer to section 2.2, :expires_in option. :-)

HTH.


Depending if this site is static or not you could go with memcached.

0

精彩评论

暂无评论...
验证码 换一张
取 消