Go back Web Development

sidekiq - How Sidekiq pass arguments to perfom method when calling perform_async

The arguments you pass to perform_async must be composed of simple JSON datatypes: string, integer, float, boolean, null, array and hash. The Sidekiq client API uses JSON.dump to send the data to Redis. The Sidekiq server pulls that JSON data from Redis and uses JSON.load to convert the data back into Ruby types to pass to your perform method. Don't pass symbols or complex Ruby objects (like Date or Time!) as those will not survive the dump/load round trip correctly.
You can see this on the console:

 options = { :a => 'b' }
 how_sidekiq_stores_the_options = JSON.dump(options)
 how_sidekiq_loads_the_options = JSON.load(how_sidekiq_stores_the_options)
 options == how_sidekiq_loads_the_options
 # => false