Reputation: 22515
I am trying to convert a Resque queue to Sidekiq. I've completed the entire setup for Sidekiq, and now am ready to add all my resque jobs to sidekiq ones.
My question is: Can I simply rename all the resque keys in redis to the corresponding sidekiq keys?
For instance, if I have a queue named "twitter", the redis key for resque is "resque:queue:twitter", but the key in sidekiq would be "queue:twitter". Could I simply rename "resque:queue:twitter" to "queue:twitter" ?
Upvotes: 6
Views: 1356
Reputation: 19863
Here is some code I used to migrate over our existing resque jobs to sidekiq. You can use this in the rails console.
['low', 'high', 'critical'].each do |queue|
p [1, queue]
old_queue = "resque:queue:#{queue}"
new_queue = "queue:#{queue}"
# $redis.ltrim new_queue, 0, 0 # can optionally clear out new queue, in case of multiple runs
vals = $redis.lrange(old_queue, 0, -1)
p [2, queue]
$redis.pipelined do
vals.each do |val|
$redis.lpush(new_queue, val)
end
end
end
You can also just set:
Sidekiq.configure_server do |config|
config.redis = { :namespace => 'resque' }
end
Sidekiq.configure_client do |config|
config.redis = { :namespace => 'resque' }
end
and it will work out of the box. But after I deployed without this, I had pending jobs in both formats, so had to use the first code I pasted to migrate things over.
Upvotes: 1
Reputation: 5962
Ok Finally Got it
There are few global command that I missed and rename
is perhaps one of them.
Where you can rename the keys If you want
do something like this
redis.rename "resque:queue:twitter","queue:twitter"
And see if it work
Cheers
Thanks for the question It just brushed up by redis knowledge
Upvotes: 6