module RailsSimpleCaching::Caching

Public Instance Methods

update_cache() click to toggle source

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

# 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) click to toggle source
# 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