Class: Shitekiq::Backend::Redis
- Inherits:
-
Object
- Object
- Shitekiq::Backend::Redis
- Defined in:
- lib/shitekiq/backend/redis.rb
Instance Method Summary collapse
-
#initialize(connection = ::Redis.new) ⇒ Redis
constructor
A new instance of Redis.
- #pop ⇒ Object
- #push(job_data) ⇒ Object
Constructor Details
#initialize(connection = ::Redis.new) ⇒ Redis
Returns a new instance of Redis.
7 8 9 |
# File 'lib/shitekiq/backend/redis.rb', line 7 def initialize(connection = ::Redis.new) @connection = connection end |
Instance Method Details
#pop ⇒ Object
15 16 17 18 19 20 |
# File 'lib/shitekiq/backend/redis.rb', line 15 def pop _queue, job = @connection.brpop('shitekiq:queue') payload = JSON.parse(job, symbolize_names: true) payload[:job] = Object.const_get(payload[:job]) payload end |
#push(job_data) ⇒ Object
11 12 13 |
# File 'lib/shitekiq/backend/redis.rb', line 11 def push(job_data) @connection.lpush('shitekiq:queue', JSON.dump(job_data)) end |