class Resque::DataStore
An interface between Resque's persistence and the actual implementation.
Constants
- HEARTBEAT_KEY
Public Class Methods
new(redis)
click to toggle source
# 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
Public Instance Methods
all_resque_keys()
click to toggle source
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
identifier()
click to toggle source
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
method_missing(sym,*args,&block)
click to toggle source
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
reconnect()
click to toggle source
Force a reconnect to Redis.
# File lib/resque/data_store.rb, line 81 def reconnect @redis.client.reconnect end
respond_to?(method,include_all=false)
click to toggle source
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) end
server_time()
click to toggle source
# File lib/resque/data_store.rb, line 93 def server_time time, _ = @redis.time Time.at(time) end