我读了官方指南。它说有page cache
, action cache
and fragment cache
,但它们不是我想要的。
我只是想缓存一个对象,而不是整个页面或视图片段,就像这样的伪代码:
def show
cache @ads, :expires_in => 1.hour do
@ads = Advertisement.all
do
end
是否可以?和memcache
or redis
?
尝试这个:
#To cache the object
Rails.cache.write('cache-key', object)
#Load the object from the cache
Rails.cache.read('cache-key')
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)