class Circuitry::Locks::Memcache

Attributes

client[RW]

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method Circuitry::Locks::Base::new
# File lib/circuitry/locks/memcache.rb, line 6
def initialize(options = {})
  super(options)

  self.client = options.fetch(:client) do
    require 'dalli'
    ::Dalli::Client.new(options[:host], options)
  end
end

Protected Instance Methods

lock(key, ttl) click to toggle source
# File lib/circuitry/locks/memcache.rb, line 17
def lock(key, ttl)
  client.add(key, (Time.now + ttl).to_i, ttl)
end
lock!(key, ttl) click to toggle source
# File lib/circuitry/locks/memcache.rb, line 21
def lock!(key, ttl)
  client.set(key, (Time.now + ttl).to_i, ttl)
end
unlock!(key) click to toggle source
# File lib/circuitry/locks/memcache.rb, line 25
def unlock!(key)
  client.delete(key)
end