From e5b550d332a58e505321213c6a2b8a4dcb91fafa Mon Sep 17 00:00:00 2001 From: Adam Bozanich Date: Sun, 15 May 2011 14:18:37 -0700 Subject: [PATCH] add HSETNX support --- lib/redis/namespace.rb | 1 + spec/redis_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/lib/redis/namespace.rb b/lib/redis/namespace.rb index 482e682..98107db 100644 --- a/lib/redis/namespace.rb +++ b/lib/redis/namespace.rb @@ -56,6 +56,7 @@ class Namespace "get" => [ :first ], "getset" => [ :first ], "hset" => [ :first ], + "hsetnx" => [ :first ], "hget" => [ :first ], "hincrby" => [ :first ], "hmget" => [ :first ], diff --git a/spec/redis_spec.rb b/spec/redis_spec.rb index ba397fc..43355d8 100644 --- a/spec/redis_spec.rb +++ b/spec/redis_spec.rb @@ -79,6 +79,12 @@ @namespaced.hincrby('bar', 'a_number', 3) @namespaced.hmget('bar', 'a_number').should == ['4'] @namespaced.hgetall('bar').should == {'key' => 'value', 'key1' => 'value1', 'a_number' => '4'} + + @namespaced.hsetnx('foonx','nx',10).should be_true + @namespaced.hsetnx('foonx','nx',12).should be_false + @namespaced.hget('foonx','nx').should == "10" + @namespaced.hkeys('foonx').should == %w{ nx } + @namespaced.hvals('foonx').should == %w{ 10 } end it "should properly intersect three sets" do