class CustomCache::ScopeCache

Public Instance Methods

cached_content() click to toggle source
# File lib/custom_cache/scope_cache.rb, line 5
def cached_content
  Rails.cache.read(self.scope) || {}
end
clear() click to toggle source
# File lib/custom_cache/scope_cache.rb, line 23
def clear
  Rails.cache.delete(scope) if scope.present?
end
read(key) click to toggle source
# File lib/custom_cache/scope_cache.rb, line 9
def read(key)
  if scope.present? && key.present?
    cached_content[key] if cached_content.present?
  end
end
write(key, content, options = {}) click to toggle source
# File lib/custom_cache/scope_cache.rb, line 15
def write(key, content, options = {})
  if scope.present? && content.present?
    cached_content.merge!(key => content)
    Rails.cache.write(scope, cached_content.merge!(key => content),
                      expires_in: (options[:expires_in] || DEFAULT_EXPIRY))
  end
end