2
我正在构建一个rails项目,最近需要一个缓存系统。Rails单元格似乎没有缓存
我正在使用Cells来构建缓存机制。
视图代码:
= cell(:payment).(:ccc)
视图模型:
class PaymentCell < Cell::ViewModel
cache :ccc
def ccc
puts '!!!!!!!!!!!!!!!!!!!!'
@record = Record.all
puts @record.size.to_s
puts @record[0].category
puts '!!!!!!!!!!!!!!!!!!!!'
render
end
end
日志:
!!!!!!!!!!!!!!!!!!!!
CACHE (0.0ms) SELECT COUNT(*) FROM `record_table`
2
CACHE (0.0ms) SELECT `record_table`.* FROM `record_table`
1_20
!!!!!!!!!!!!!!!!!!!!
的问题是,总是日志像以上。 似乎每次都会执行“ccc”操作。 细胞github上说:
For every cell class you can define caching per state. Without any configuration the cell will run and render the state once.
In following invocations, the cached fragment is returned.
但缓存似乎并不在我的项目工作...