module RedisCacheable::ActiveRecord::ClassMethods

Public Instance Methods

cache_all(options = {}) click to toggle source

cache all persisted records @param [Hash] options pass to find_each method @return [void]

# File lib/redis_cacheable/active_record.rb, line 21
def cache_all(options = {})
  find_each(options) do |record|
    record.cache_to_redis
  end

  redis do |conn|
    conn.save
  end
end
find_from_redis(key) click to toggle source

@param [Object] key @return [ActiveRecord::Base] ActiveRecord instantiated object

Calls superclass method
# File lib/redis_cacheable/active_record.rb, line 12
def find_from_redis(key)
  if data = super(key)
    instantiate(data)
  end
end