lib/redis/lock.rb in redis-objects-1.4.3 vs lib/redis/lock.rb in redis-objects-1.5.0
- old
+ new
@@ -9,23 +9,15 @@
# class to define a lock.
#
class Lock < BaseObject
class LockTimeout < StandardError; end #:nodoc:
- attr_reader :key, :options
def initialize(key, *args)
super(key, *args)
@options[:timeout] ||= 5
@options[:init] = false if @options[:init].nil? # default :init to false
redis.setnx(key, @options[:start]) unless @options[:start] == 0 || @options[:init] === false
end
-
- # Clear the lock. Should only be needed if there's a server crash
- # or some other event that gets locks in a stuck state.
- def clear
- redis.del(key)
- end
- alias_method :delete, :clear
def value
nil
end