I'm building a rails project, which recently needs a cache system.
I'm using Cells to build cache mechanism.
view code:
= cell(:payment).(:ccc)
viewmodel:
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
log:
!!!!!!!!!!!!!!!!!!!!
CACHE (0.0ms) SELECT COUNT(*) FROM `record_table`
2
CACHE (0.0ms) SELECT `record_table`.* FROM `record_table`
1_20
!!!!!!!!!!!!!!!!!!!!
The question is the log always like above. It seems that the "ccc" action executes every time. The Cells github says :
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.
But the caching seems not working in my project...