class Gemstash::LruReduxClient

Wrapper around the lru_redux gem to behave like a dalli Memcached client.

Constants

EXPIRY
MAX_SIZE

Public Class Methods

new() click to toggle source
# File lib/gemstash/cache.rb, line 59
def initialize
  @cache = LruRedux::TTL::ThreadSafeCache.new MAX_SIZE, EXPIRY
end

Public Instance Methods

alive!() click to toggle source
# File lib/gemstash/cache.rb, line 63
def alive!
  true
end
get_multi(keys) { |key, value| ... } click to toggle source
# File lib/gemstash/cache.rb, line 67
def get_multi(keys)
  keys.each do |key|
    found = true
    # Atomic fetch... don't rely on nil meaning missing
    value = @cache.fetch(key) { found = false }
    next unless found

    yield(key, value)
  end
end
set(key, value, expiry) click to toggle source
# File lib/gemstash/cache.rb, line 78
def set(key, value, expiry)
  @cache[key] = value
end