From cc09dc3477d924bf5bfb447275b5a8c01c22c9e3 Mon Sep 17 00:00:00 2001 From: Nils Mueller Date: Mon, 22 Jun 2020 15:13:31 +0200 Subject: [PATCH] Support variadic exists and exists? redis-rb 4.2.0 made `exists` variadic and introduced `exists?` --- lib/redis/namespace.rb | 3 ++- spec/redis_spec.rb | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/redis/namespace.rb b/lib/redis/namespace.rb index 56295fa..b8911b9 100644 --- a/lib/redis/namespace.rb +++ b/lib/redis/namespace.rb @@ -68,7 +68,8 @@ class Namespace "decrby" => [ :first ], "del" => [ :all ], "dump" => [ :first ], - "exists" => [ :first ], + "exists" => [ :all ], + "exists?" => [ :all ], "expire" => [ :first ], "expireat" => [ :first ], "eval" => [ :eval_style ], diff --git a/spec/redis_spec.rb b/spec/redis_spec.rb index 4278692..eaf6e52 100644 --- a/spec/redis_spec.rb +++ b/spec/redis_spec.rb @@ -140,10 +140,22 @@ it 'should be able to use a namespace with setbit' do @namespaced.setbit('virgin_key', 1, 1) - expect(@namespaced.exists('virgin_key')).to be true + expect(@namespaced.exists?('virgin_key')).to be true expect(@namespaced.get('virgin_key')).to eq(@namespaced.getrange('virgin_key',0,-1)) end + it 'should be able to use a namespace with exists' do + @namespaced.set('foo', 1000) + @namespaced.set('bar', 2000) + expect(@namespaced.exists('foo', 'bar')).to eq(2) + end + + it 'should be able to use a namespace with exists?' do + @namespaced.set('foo', 1000) + @namespaced.set('bar', 2000) + expect(@namespaced.exists?('does_not_exist', 'bar')).to eq(true) + end + it 'should be able to use a namespace with bitpos' do @namespaced.setbit('bit_map', 42, 1) expect(@namespaced.bitpos('bit_map', 0)).to eq(0)