Module: ScopedCacheKeys

Defined in:
lib/scoped_cache_keys.rb,
lib/scoped_cache_keys/version.rb

Constant Summary collapse

VERSION =
'0.2.0'

Instance Method Summary collapse

Instance Method Details

#expire_scoped_cache_key(scope) ⇒ Object



9
10
11
# File 'lib/scoped_cache_keys.rb', line 9

def expire_scoped_cache_key(scope)
  Rails.cache.delete(build_scoped_cache_key(scope))
end

#scoped_cache_key(scope, options = nil) ⇒ Object



4
5
6
7
# File 'lib/scoped_cache_keys.rb', line 4

def scoped_cache_key(scope, options = nil)
  base_key = Rails.cache.fetch(build_scoped_cache_key([scope]), options) { Time.now.to_f }
  build_scoped_cache_key [scope, base_key]
end