Module: Resque::Plugins::DynamicQueues::Attributes
- Defined in:
- lib/resque/plugins/dynamic_queues/attributes.rb
Instance Method Summary collapse
- #get_dynamic_queue(key, fallback = ['*']) ⇒ Object
- #get_dynamic_queues ⇒ Object
- #set_dynamic_queue(key, values) ⇒ Object
- #set_dynamic_queues(dynamic_queues) ⇒ Object
Instance Method Details
#get_dynamic_queue(key, fallback = ['*']) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/resque/plugins/dynamic_queues/attributes.rb', line 10 def get_dynamic_queue(key, fallback=['*']) data = redis.hget(DYNAMIC_QUEUE_KEY, key) queue_names = Resque.decode(data) if queue_names.nil? || queue_names.size == 0 data = redis.hget(DYNAMIC_QUEUE_KEY, FALLBACK_KEY) queue_names = Resque.decode(data) end if queue_names.nil? || queue_names.size == 0 queue_names = fallback end return queue_names end |
#get_dynamic_queues ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/resque/plugins/dynamic_queues/attributes.rb', line 43 def get_dynamic_queues result = {} queues = redis.hgetall(DYNAMIC_QUEUE_KEY) queues.each {|k, v| result[k] = Resque.decode(v) } result[FALLBACK_KEY] ||= ['*'] return result end |
#set_dynamic_queue(key, values) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/resque/plugins/dynamic_queues/attributes.rb', line 26 def set_dynamic_queue(key, values) if values.nil? or values.size == 0 redis.hdel(DYNAMIC_QUEUE_KEY, key) else redis.hset(DYNAMIC_QUEUE_KEY, key, Resque.encode(values)) end end |
#set_dynamic_queues(dynamic_queues) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/resque/plugins/dynamic_queues/attributes.rb', line 34 def set_dynamic_queues(dynamic_queues) redis.multi do redis.del(DYNAMIC_QUEUE_KEY) dynamic_queues.each do |k, v| set_dynamic_queue(k, v) end end end |