class DistributeReads::CacheStore

Public Instance Methods

read(key) click to toggle source
# File lib/distribute_reads/cache_store.rb, line 3
def read(key)
  memory_cached = memory_store.read(key)
  return nil if memory_cached == :nil
  return memory_cached if memory_cached

  store_cached = store.try(:read, key)
  memory_store.write(key, store_cached || :nil)
  store_cached
end
write(*args) click to toggle source
# File lib/distribute_reads/cache_store.rb, line 13
def write(*args)
  memory_store.write(*args)
  store.try(:write, *args)
end

Private Instance Methods

memory_store() click to toggle source

use ActiveSupport::Cache::MemoryStore instead?

# File lib/distribute_reads/cache_store.rb, line 21
def memory_store
  @memory_store ||= Makara::Cache::MemoryStore.new
end
store() click to toggle source
# File lib/distribute_reads/cache_store.rb, line 25
def store
  @store ||= Rails.cache
end