Class: Shitekiq::Backend::Redis

Inherits:
Object
  • Object
show all
Defined in:
lib/shitekiq/backend/redis.rb

Instance Method Summary collapse

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

#popObject



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