An interface between Resque’s persistence and the actual implementation.
Returns an array of all known Resque keys in Redis. Redis’ KEYS operation is O(N) for the keyspace, so be careful - this can be slow for big databases.
# File lib/resque/data_store.rb, line 87 def all_resque_keys @redis.keys("*").map do |key| key.sub("#{@redis.namespace}:", '') end end
Get a string identifying the underlying server. Probably should be private, but was public so must stay public
# File lib/resque/data_store.rb, line 69 def identifier # support 1.x versions of redis-rb if @redis.respond_to?(:server) @redis.server elsif @redis.respond_to?(:nodes) # distributed @redis.nodes.map { |n| n.id }.join(', ') else @redis.client.id end end
Compatibility with any non-Resque classes that were using Resque#redis as a way to access Redis
# File lib/resque/data_store.rb, line 57 def method_missing(sym,*args,&block) # TODO: deprecation warning? @redis.send(sym,*args,&block) end
Force a reconnect to Redis.
# File lib/resque/data_store.rb, line 81 def reconnect @redis.client.reconnect end
make use respond like redis
# File lib/resque/data_store.rb, line 63 def respond_to?(method,include_all=false) @redis.respond_to?(method,include_all) || super end
# File lib/resque/data_store.rb, line 93 def server_time time, _ = redis_time_available? ? @redis.time : Time.now Time.at(time) end
# File lib/resque/data_store.rb, line 9 def initialize(redis) @redis = redis @queue_access = QueueAccess.new(@redis) @failed_queue_access = FailedQueueAccess.new(@redis) @workers = Workers.new(@redis) @stats_access = StatsAccess.new(@redis) end