Sha256: 93d4b4f1cecfcc3b3e0bab8f432a7d1bfc16b36a1efb93c560c7327f09e9c65d
Contents?: true
Size: 984 Bytes
Versions: 1
Compression:
Stored size: 984 Bytes
Contents
class RedisLock class MultiLock extend Forwardable attr_reader :keys, :locks, :opts def_delegators :locks, :any?, :all?, :each, :map def initialize(*args) @opts = extract_options!(args) @keys = args @locks = @keys.map do |k| RedisLock.new(k, @opts) end end def extract_options!(args) args.last.is_a?(::Hash) ? args.pop : {} end def set(ttl, opts = {}) map { |l| l.set(ttl, opts) }.all?{ |e| e === true } end def config RedisLock.config end def delete map(&:delete).all?{ |e| e === true } end alias_method :unlock!, :delete alias_method :open!, :delete alias_method :remove, :delete def open? all?(&:open?) end alias_method :unlocked?, :open? def key map(&:key).join(', ') end def locked? any?(&:locked?) end alias_method :exists?, :locked? alias_method :in_use?, :locked? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
redis_lock-0.4.4 | lib/redis_lock/multi_lock.rb |