Class: RecordCache::Strategy::FullTableCache

Inherits:
Base
  • Object
show all
Defined in:
lib/record_cache/strategy/full_table_cache.rb

Constant Summary collapse

FULL_TABLE =
'full-table'

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#attribute, #fetch, #initialize, #invalidate

Constructor Details

This class inherits a constructor from RecordCache::Strategy::Base

Class Method Details

.parse(base, record_store, options) ⇒ Object

parse the options and return (an array of) instances of this strategy



7
8
9
10
11
12
# File 'lib/record_cache/strategy/full_table_cache.rb', line 7

def self.parse(base, record_store, options)
  return nil unless options[:full_table]
  return nil unless base.table_exists?

  FullTableCache.new(base, :full_table, record_store, options)
end

Instance Method Details

#cacheable?(query) ⇒ Boolean

Can the cache retrieve the records based on this query?

Returns:

  • (Boolean)


15
16
17
# File 'lib/record_cache/strategy/full_table_cache.rb', line 15

def cacheable?(query)
  true
end

#record_change(record, action) ⇒ Object

Clear the cache on any record change



20
21
22
# File 'lib/record_cache/strategy/full_table_cache.rb', line 20

def record_change(record, action)
  version_store.delete(cache_key(FULL_TABLE))
end