Class: SmartCollection::CacheManager

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_collection/cache_manager.rb,
lib/smart_collection/cache_manager/table.rb,
lib/smart_collection/cache_manager/cache_store.rb

Direct Known Subclasses

CacheStore, Table

Defined Under Namespace

Classes: CacheStore, Table

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model:, config:) ⇒ CacheManager

Returns a new instance of CacheManager.



13
14
15
16
# File 'lib/smart_collection/cache_manager.rb', line 13

def initialize model:, config:
  @model = model
  @config = config
end

Class Method Details

.determine_class(config) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/smart_collection/cache_manager.rb', line 4

def self.determine_class config
  case
  when config.dig(:cached_by, :table)
    SmartCollection::CacheManager::Table
  when config.dig(:cached_by, :cache_store)
    SmartCollection::CacheManager::CacheStore
  end
end

Instance Method Details

#cache_exists?(owner) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/smart_collection/cache_manager.rb', line 26

def cache_exists? owner
  raise NotImplementedError
end

#expires_inObject



30
31
32
# File 'lib/smart_collection/cache_manager.rb', line 30

def expires_in
  @config.cache_config[:expires_in] || 1.hour
end

#read_scope(owner) ⇒ Object

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/smart_collection/cache_manager.rb', line 22

def read_scope owner
  raise NotImplementedError
end

#update(owner) ⇒ Object

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/smart_collection/cache_manager.rb', line 18

def update owner
  raise NotImplementedError
end