Module: ActiveRecordCache::ClassMethods
- Defined in:
- lib/active_record_cache.rb
Instance Method Summary collapse
- #expire_cache_entry(id) ⇒ Object
-
#use_record_cache(options = {}) ⇒ Object
Call this method to add a cache to a model.
Instance Method Details
#expire_cache_entry(id) ⇒ Object
69 70 71 |
# File 'lib/active_record_cache.rb', line 69 def expire_cache_entry(id) self.record_cache.expire(id) end |
#use_record_cache(options = {}) ⇒ Object
Call this method to add a cache to a model. The options allowed are:
-
:cache - the ActiveSupport::Cache::Store instance to use. By default it will use Rails.cache.
-
:expires_in - the number of seconds until cache entries will be automatically refreshed (defaults to 1 hour)
62 63 64 65 66 67 |
# File 'lib/active_record_cache.rb', line 62 def use_record_cache( = {}) class_attribute :record_cache, :instance_reader => false, :instance_writer => false self.record_cache = RecordCache.new(self, ) scope :from_database, scoped.from_database scope :from_cache, scoped.from_cache end |