Skip to content

Commit d86dc7c

Browse files
committed
Merge pull request #55 from simplymeasured/mapped_msetnx
add namespace support to mapped_msetnx commands
2 parents 2e52df5 + cb8c2fb commit d86dc7c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/redis/namespace.rb

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class Namespace
105105
"mapped_hmget" => [ :first ],
106106
"mapped_mget" => [ :all, :all ],
107107
"mapped_mset" => [ :all ],
108+
"mapped_msetnx" => [ :all ],
108109
"mget" => [ :all ],
109110
"monitor" => [ :monitor ],
110111
"move" => [ :first ],

spec/redis_spec.rb

+9
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@
142142
@namespaced.mapped_mget('foo', 'baz', 'bar').should eq({ 'foo' => '1000', 'bar' => '2000', 'baz' => nil})
143143
end
144144

145+
it "should be able to use a namespace with mapped_msetnx" do
146+
puts @namespaced.keys.inspect
147+
@namespaced.set('foo','1')
148+
@namespaced.mapped_msetnx('foo'=>'1000', 'bar'=>'2000').should be_false
149+
@namespaced.mapped_mget('foo', 'bar').should == { 'foo' => '1', 'bar' => nil }
150+
@namespaced.mapped_msetnx('bar'=>'2000', 'baz'=>'1000').should be_true
151+
@namespaced.mapped_mget('foo', 'bar').should == { 'foo' => '1', 'bar' => '2000' }
152+
end
153+
145154
it "should be able to use a namespace with hashes" do
146155
@namespaced.hset('foo', 'key', 'value')
147156
@namespaced.hset('foo', 'key1', 'value1')

0 commit comments

Comments
 (0)