lib/searchkick/reindex_queue.rb in searchkick-2.1.0 vs lib/searchkick/reindex_queue.rb in searchkick-2.1.1

- old
+ new

@@ -3,38 +3,34 @@ attr_reader :name def initialize(name) @name = name - raise Searchkick::Error, "Searchkick.redis not set" unless redis + raise Searchkick::Error, "Searchkick.redis not set" unless Searchkick.redis end def push(record_id) - redis.lpush(redis_key, record_id) + Searchkick.with_redis { |r| r.lpush(redis_key, record_id) } end # TODO use reliable queuing def reserve(limit: 1000) record_ids = Set.new - while record_ids.size < limit && record_id = redis.rpop(redis_key) + while record_ids.size < limit && record_id = Searchkick.with_redis { |r| r.rpop(redis_key) } record_ids << record_id end record_ids.to_a end def clear - redis.del(redis_key) + Searchkick.with_redis { |r| r.del(redis_key) } end def length - redis.llen(redis_key) + Searchkick.with_redis { |r| r.llen(redis_key) } end private - - def redis - Searchkick.redis - end def redis_key "searchkick:reindex_queue:#{name}" end end