Class: RestrictCache::CacheCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/restrict_cache/cache_collection.rb,
lib/restrict_cache/cache_collection/inner_cache.rb,
lib/restrict_cache/cache_collection/custom_cache.rb,
lib/restrict_cache/cache_collection/active_record_cache.rb

Defined Under Namespace

Modules: CacheKey Classes: ActiveRecordCache, CustomCache, InnerCache

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCacheCollection

Returns a new instance of CacheCollection.



39
40
41
# File 'lib/restrict_cache/cache_collection.rb', line 39

def initialize
  @cache_collection = {}
end

Class Method Details

.build_inner_cache(key) ⇒ Object



28
29
30
# File 'lib/restrict_cache/cache_collection.rb', line 28

def build_inner_cache(key)
  const_get(key.to_s.classify, false).new
end

Instance Method Details

#[](key) ⇒ Object



47
48
49
50
# File 'lib/restrict_cache/cache_collection.rb', line 47

def [](key)
  return nil unless key
  @cache_collection[key]
end

#add(content) ⇒ Object



43
44
45
# File 'lib/restrict_cache/cache_collection.rb', line 43

def add(content)
  inner_cache(CacheKey.get(content)).add(content)
end

#cache_keysObject



52
53
54
# File 'lib/restrict_cache/cache_collection.rb', line 52

def cache_keys
  CacheKey::ALL
end