Class: DRbQueue::Store::Redis
- Inherits:
-
DRbQueue::Store
- Object
- DRbQueue::Store
- DRbQueue::Store::Redis
- Defined in:
- lib/drb_queue/store/redis.rb
Constant Summary
Constants inherited from DRbQueue::Store
Instance Method Summary collapse
- #each_persisted_work ⇒ Object
-
#initialize(options = {}) ⇒ Redis
constructor
A new instance of Redis.
- #persist(work) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Redis
Returns a new instance of Redis.
7 8 9 |
# File 'lib/drb_queue/store/redis.rb', line 7 def initialize( = {}) @redis = ::Redis::Namespace.new(:DRbQueue, :redis => .fetch(:redis, lambda { ::Redis.new }).call) end |
Instance Method Details
#each_persisted_work ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/drb_queue/store/redis.rb', line 15 def each_persisted_work return enum_for(:each_persisted_work) unless block_given? while serialized_work = redis.lpop(persistence_key) yield(serialized_work) end end |
#persist(work) ⇒ Object
11 12 13 |
# File 'lib/drb_queue/store/redis.rb', line 11 def persist(work) redis.rpush(persistence_key, work.serialize) end |