lib/qpush/web/redis.rb in qpush-0.1.6 vs lib/qpush/web/redis.rb in qpush-0.1.7

- old
+ new

@@ -10,7 +10,39 @@ def redis_pool @redis_pool ||= QPush::Base::RedisPool.create(Web.config.redis_pool, Web.config.redis_url) end end + + class RedisKeys + KEYS = [:delay, + :queue, + :perform, + :stats, + :heart, + :crons, + :history, + :morgue] + + attr_reader :delay, :queue, :perform, :stats, :heart, + :crons, :history, :morgue + + def initialize(options = {}) + @namespace = options[:namespace] || 'default' + @priorities = options[:priorities] || 5 + build_keyspaces + end + + def perform_list + @perform_list ||= (1..@priorities).collect { |num| "#{perform}:#{num}" } + end + + private + + def build_keyspaces + KEYS.each do |key| + instance_variable_set("@#{key}", "#{QPush::Base::KEY}:#{@namespace}:#{key}") + end + end + end end end