lib/redis/lock.rb in redis-objects-0.1.0 vs lib/redis/lock.rb in redis-objects-0.1.1

- old
+ new

@@ -8,14 +8,14 @@ # class Lock class LockTimeout < StandardError; end #:nodoc: attr_reader :key, :options, :redis - def initialize(key, options={}) + def initialize(key, redis=$redis, options={}) @key = key + @redis = redis @options = options @options[:timeout] ||= 5 - @redis = options[:redis] || $redis || Redis::Objects.redis @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. \ No newline at end of file