Module: AkidoLib::ModelClassExtensions
- Defined in:
- lib/caching.rb
Instance Method Summary collapse
Instance Method Details
#cache! ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/caching.rb', line 17 def cache! model = self.to_s.demodulize cache = Redis::HashKey.new(model) records = self.search.to_a records.each do |record| cache[record.id] = record.to_json end end |
#cached ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/caching.rb', line 28 def cached model = self.class.to_s.demodulize Redis::HashKey.new(model).values.map do |record| self.new(JSON.parse(record)) end end |