Module: RailsSimpleCaching::Caching

Extended by:
ActiveSupport::Concern
Defined in:
lib/rails_simple_caching/caching.rb,
lib/rails_simple_caching/caching/class_methods.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#update_cacheObject

Updates all the cached attributes. Returns true if every update is successful.



20
21
22
# File 'lib/rails_simple_caching/caching.rb', line 20

def update_cache
  self.class.cached_attributes.map { |attr| update_cached(attr) }.none?(false)
end

#update_cached(attribute) ⇒ Object



11
12
13
14
15
16
# File 'lib/rails_simple_caching/caching.rb', line 11

def update_cached(attribute)
  contents = public_send(attribute)
  key = "#{cache_key_with_version}/#{attribute}"
  success = Rails.cache.write(key, contents)
  success ? contents : false
end