class Gemstash::Cache

Cache object which knows about what things are cached and what keys to use for them. Under the hood is either a Memcached client via the dalli gem, or an in memory client via the lru_redux gem.

Constants

EXPIRY

Public Class Methods

new(client) click to toggle source
# File lib/gemstash/cache.rb, line 15
def initialize(client)
  @client = client
end

Public Instance Methods

authorization(auth_key) click to toggle source
# File lib/gemstash/cache.rb, line 19
def authorization(auth_key)
  @client.get("auths/#{auth_key}")
end
dependencies(scope, gems) { |sub(key_prefix, ""), value| ... } click to toggle source
# File lib/gemstash/cache.rb, line 31
def dependencies(scope, gems)
  key_prefix = "deps/v1/#{scope}/"
  keys = gems.map {|g| "#{key_prefix}#{g}" }

  @client.get_multi(keys) do |key, value|
    yield(key.sub(key_prefix, ""), value)
  end
end
invalidate_authorization(auth_key) click to toggle source
# File lib/gemstash/cache.rb, line 27
def invalidate_authorization(auth_key)
  @client.delete("auths/#{auth_key}")
end
invalidate_gem(scope, gem) click to toggle source
# File lib/gemstash/cache.rb, line 44
def invalidate_gem(scope, gem)
  @client.delete("deps/v1/#{scope}/#{gem}")
  Gemstash::SpecsBuilder.invalidate_stored if scope == "private"
end
set_authorization(auth_key, value) click to toggle source
# File lib/gemstash/cache.rb, line 23
def set_authorization(auth_key, value)
  @client.set("auths/#{auth_key}", value, EXPIRY)
end
set_dependency(scope, gem, value) click to toggle source
# File lib/gemstash/cache.rb, line 40
def set_dependency(scope, gem, value)
  @client.set("deps/v1/#{scope}/#{gem}", value, EXPIRY)
end