From 9e7cd1d8a4a7140a13545b47abcaf1b006390cda Mon Sep 17 00:00:00 2001 From: Kamal Joshi Date: Mon, 13 Feb 2017 18:43:40 +0530 Subject: [PATCH] Call encode once to remove the possibility of different encoded job values. --- lib/resque/scheduler/delaying_extensions.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/resque/scheduler/delaying_extensions.rb b/lib/resque/scheduler/delaying_extensions.rb index ec7606f0..136d1ba9 100644 --- a/lib/resque/scheduler/delaying_extensions.rb +++ b/lib/resque/scheduler/delaying_extensions.rb @@ -62,11 +62,13 @@ def enqueue_in_with_queue(queue, number_of_seconds_from_now, # if O(log(n)). Returns true if it's the first job to be scheduled at # that time, else false def delayed_push(timestamp, item) + encoded_job = encode(item) + # First add this item to the list for this timestamp - redis.rpush("delayed:#{timestamp.to_i}", encode(item)) + redis.rpush("delayed:#{timestamp.to_i}", encoded_job) # Store the timestamps at with this item occurs - redis.sadd("timestamps:#{encode(item)}", "delayed:#{timestamp.to_i}") + redis.sadd("timestamps:#{encoded_job}", "delayed:#{timestamp.to_i}") # Now, add this timestamp to the zsets. The score and the value are # the same since we'll be querying by timestamp, and we don't have