Skip to content

Commit

Permalink
Fix deprecation warnings with redis-rb v4.8.0 (#356)
Browse files Browse the repository at this point in the history
redis-rb v4.8.0 gives a deprecation warning when calling `sadd` and
`srem` with a single argument:
https://github.com/redis/redis-rb/blob/4.x/CHANGELOG.md#480

```
Redis#sadd will always return an Integer in Redis 5.0.0. Use Redis#sadd? instead.
```

Resolving the deprecation warning by following Sidekiq's approach of
wrapping the argument as an array:
sidekiq/sidekiq@09dacfe

Fixes #355
  • Loading branch information
cgunther authored Sep 6, 2022
1 parent 313bf34 commit 1f9cc7d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## Unreleased

- Fix deprecation warnings with redis-rb v4.8.0 (https://github.com/ondrejbartas/sidekiq-cron/pull/356

## 1.7.0

- Enable to use cron notation in natural language (ie `every 30 minutes`) (https://github.com/ondrejbartas/sidekiq-cron/pull/312)
Expand Down
4 changes: 2 additions & 2 deletions lib/sidekiq/cron/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def save
Sidekiq.redis do |conn|

# Add to set of all jobs
conn.sadd self.class.jobs_key, redis_key
conn.sadd self.class.jobs_key, [redis_key]

# Add informations for this job!
conn.hmset redis_key, *hash_to_redis(to_hash)
Expand Down Expand Up @@ -502,7 +502,7 @@ def add_jid_history(jid)
def destroy
Sidekiq.redis do |conn|
# Delete from set.
conn.srem self.class.jobs_key, redis_key
conn.srem self.class.jobs_key, [redis_key]

# Delete runned timestamps.
conn.del job_enqueued_key
Expand Down
2 changes: 1 addition & 1 deletion test/unit/job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@
Sidekiq::Cron::Job.create(@args.merge(name: "Test3"))

Sidekiq.redis do |conn|
conn.sadd Sidekiq::Cron::Job.jobs_key, "some_other_key"
conn.sadd Sidekiq::Cron::Job.jobs_key, ["some_other_key"]
end

assert_equal Sidekiq::Cron::Job.all.size, 3, "All have to return only valid 3 jobs"
Expand Down

0 comments on commit 1f9cc7d

Please sign in to comment.