From 773cf045b27be93511dc50c7e186cad863a8e215 Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Thu, 8 Dec 2022 06:48:44 +0800 Subject: [PATCH] DEV: Update redis gem to 4.8.0 (#19350) --- Gemfile.lock | 2 +- lib/discourse_redis.rb | 4 ++-- spec/lib/discourse_redis_spec.rb | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6cce772e8e4..00c690dc74d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -341,7 +341,7 @@ GEM msgpack (>= 0.4.3) optimist (>= 3.0.0) rchardet (1.8.0) - redis (4.7.1) + redis (4.8.0) redis-namespace (1.9.0) redis (>= 4) regexp_parser (2.6.1) diff --git a/lib/discourse_redis.rb b/lib/discourse_redis.rb index 0230eaf006a..4c661cc9afe 100644 --- a/lib/discourse_redis.rb +++ b/lib/discourse_redis.rb @@ -50,8 +50,8 @@ class DiscourseRedis :hdel, :hexists, :hget, :hgetall, :hincrby, :hincrbyfloat, :hkeys, :hlen, :hmget, :hmset, :hset, :hsetnx, :hvals, :incr, :incrby, :incrbyfloat, :lindex, :linsert, :llen, :lpop, :lpush, :lpushx, :lrange, :lrem, :lset, :ltrim, :mapped_hmset, :mapped_hmget, :mapped_mget, :mapped_mset, :mapped_msetnx, :move, :mset, - :msetnx, :persist, :pexpire, :pexpireat, :psetex, :pttl, :rename, :renamenx, :rpop, :rpoplpush, :rpush, :rpushx, :sadd, :scard, - :sdiff, :set, :setbit, :setex, :setnx, :setrange, :sinter, :sismember, :smembers, :sort, :spop, :srandmember, :srem, :strlen, + :msetnx, :persist, :pexpire, :pexpireat, :psetex, :pttl, :rename, :renamenx, :rpop, :rpoplpush, :rpush, :rpushx, :sadd, :sadd?, :scard, + :sdiff, :set, :setbit, :setex, :setnx, :setrange, :sinter, :sismember, :smembers, :sort, :spop, :srandmember, :srem, :srem?, :strlen, :sunion, :ttl, :type, :watch, :zadd, :zcard, :zcount, :zincrby, :zrange, :zrangebyscore, :zrank, :zrem, :zremrangebyrank, :zremrangebyscore, :zrevrange, :zrevrangebyscore, :zrevrank, :zrangebyscore, :dump, :restore].each do |m| diff --git a/spec/lib/discourse_redis_spec.rb b/spec/lib/discourse_redis_spec.rb index e6564abc56e..acf3cc96bfc 100644 --- a/spec/lib/discourse_redis_spec.rb +++ b/spec/lib/discourse_redis_spec.rb @@ -115,6 +115,26 @@ RSpec.describe DiscourseRedis do end end + describe '#sadd?' do + it "should send the right command with the right key prefix to redis" do + redis = DiscourseRedis.new + + redis.without_namespace.expects(:sadd?).with("default:testset", "1", anything) + + redis.sadd?("testset", "1") + end + end + + describe '#srem?' do + it "should send the right command with the right key prefix to redis" do + redis = DiscourseRedis.new + + redis.without_namespace.expects(:srem?).with("default:testset", "1", anything) + + redis.srem?("testset", "1") + end + end + describe 'when namespace is disabled' do let(:redis) { DiscourseRedis.new(nil, namespace: false) }