如何使用memcached执行缓存



我使用memcached缓存表记录。我的代码如下

Rails.cache.fetch('custom_profiles') do
 @custom_profiles=CustomProfile.where(:status=>"Active") 
end

但是无论何时添加了新记录,它都不会被更新。我想在表被编辑时更新这个变量。如果你有任何想法,请与我分享。

您可以像这样从缓存中删除项

Rails.cache.delete('custom_profiles')

你可能想在一些回调或观察者

最新更新