Remove Redis 4.2 warnings. (PR #450)

Apps on Redis 4.2 and up will see a warning due to Make `exists` variadic. · redis/redis-rb@3257527 · GitHub


@casperisfine what should our approach be here.

Our dependency on redis is “weak” in that there is no explicit dependency. exists? may no exist in earlier redis gems.

Should we monkey patch it in and keep this code?

We can just implement exists? since it isn’t hard. Essentially just calling[:exists, key])

as long as it is backwards compatible with reasonable redis gem releases for whatever definition of reasonable that we can come up with

We’re only using a single key so it should be backwards compatible all the way

Should we monkey patch it in and keep this code?

Yeah, based on your constraints I’d do this:

If the redis_store.rb file was autoloaded, you could go with a slightly cleaner alternative:

unless Redis.method_defined?(:exists?)
  module RedisExistsRefinement
    refine Redis do
      def exists?(key)
  using RedisExistsRefinement

The title of this pull request changed from “Upgrade Redis to 4.2.1.” to "Remove Redis 4.2 warnings.