Reputation: 1
I am new to redis and have not been able to find any guides to create what I have in my head. I want to create multiple Jobs each doing a simple process.
Job one: Generate a new, random number between 1-100 every 10 seconds. Job two: Keep a running total of the sum of Job one. Job three: Generate a new, random letter from the English alphabet once every 30 seconds.
If anyone knows a simple script that could help me achieve this little problem it would be a great help.
I don't really know where to begin. This ( http://redis.io/commands/rpoplpush ) might be a good resource but I'm not sure which commands will be best to use. Any help would be much appreciated.
-Vishnu
Upvotes: 0
Views: 100
Reputation: 23713
From my experience with background jobs and Ruby, I strongly recommend using Sidekiq. It uses Redis to manage the queues, but you don't have to worry about it rpoplpush or any Redis command. Sidekiq does it for you.
Now, it seems that you have three kind of jobs, and job 2 depends on job 1. You have several approaches to keep a running total of the sum of job one, but for dependency between jobs I would suggest this SuperWorker.
If you get stuck on writing the actual code, come again and I am sure it will be easier to help you. But Sidekiq should be a good starting point to manage jobs in Ruby.
Upvotes: 2