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 86
def all_resque_keys
  @redis.keys("*").map do |key|
    key.sub("#{@redis.namespace}:", '')
  end
end
decremet_stat(*args) click to toggle source
# File lib/resque/data_store.rb, line 57
def decremet_stat(*args)
  warn '[Resque] [Deprecation] Resque::DataStore #decremet_stat method is deprecated (please use #decrement_stat)'
  decrement_stat(*args)
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 75
def identifier
  @redis.inspect
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 63
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 80
def reconnect
  @redis._client.reconnect
end
respond_to?(method,include_all=false) click to toggle source

make use respond like redis

Calls superclass method
# File lib/resque/data_store.rb, line 69
def respond_to?(method,include_all=false)
  @redis.respond_to?(method,include_all) || super
end
server_time() click to toggle source
# File lib/resque/data_store.rb, line 92
def server_time
  time, _ = @redis.time
  Time.at(time)
end