Module: RedisCacheable::ActiveRecord::ClassMethods
- Defined in:
- lib/redis_cacheable/active_record.rb
Instance Method Summary collapse
-
#cache_all(options = {}) ⇒ void
cache all persisted records.
-
#find_from_redis(key) ⇒ ActiveRecord::Base
ActiveRecord instantiated object.
Instance Method Details
#cache_all(options = {}) ⇒ void
This method returns an undefined value.
cache all persisted records
21 22 23 24 25 26 27 28 29 |
# File 'lib/redis_cacheable/active_record.rb', line 21 def cache_all( = {}) find_each() do |record| record.cache_to_redis end redis do |conn| conn.save end end |
#find_from_redis(key) ⇒ ActiveRecord::Base
Returns ActiveRecord instantiated object.
12 13 14 15 16 |
# File 'lib/redis_cacheable/active_record.rb', line 12 def find_from_redis(key) if data = super(key) instantiate(data) end end |