#
Storing Arbitrary Data with Redis
Jobly comes bundled with Sidekiq::Status which has a built in ability allowing you to store and use arbitrary data in its Redis database.
jobs/hello.rb
class Hello < Jobly::Job
def execute(name: 'bob')
# Store arbitrary data
store vino: 'veritas'
# Retrieve data.
vino = retrieve :vino
end
end
Note that:
- Values are always stored as a
String
, so you will need to convert them to other types when appropriate. - When
retrieve
does not find the key,nil
is returned. - Stored keys are available across jobs.