Skip to content
Browse files

Add hash commands and test their usage

  • Loading branch information...
1 parent 191a104 commit 241bdbfa3c64398aa4bd71c6daf432ffb2b9c0ef @akahn akahn committed with defunkt Mar 27, 2010
Showing with 17 additions and 0 deletions.
  1. +8 −0 lib/redis/namespace.rb
  2. +9 −0 spec/redis_spec.rb
View
8 lib/redis/namespace.rb
@@ -54,6 +54,14 @@ class Namespace
"flushdb" => [],
"get" => [ :first ],
"getset" => [ :first ],
+ "hset" => [ :first ],
+ "hget" => [ :first ],
+ "hdel" => [ :first ],
+ "hexists" => [ :first ],
+ "hlen" => [ :first ],
+ "hkeys" => [ :first ],
+ "hvals" => [ :first ],
+ "hgetall" => [ :first ],
"incr" => [ :first ],
"incrby" => [ :first ],
"info" => [],
View
9 spec/redis_spec.rb
@@ -65,6 +65,15 @@
@namespaced.mapped_mget('foo', 'baz', 'bar').should == { 'foo' => '1000', 'bar' => '2000'}
end
+ it "should be able to use a namespace with hashes" do
+ @namespaced.hset('foo', 'key', 'value')
+ @namespaced.hset('foo', 'key1', 'value1')
+ @namespaced.hget('foo', 'key').should == 'value'
+ @namespaced.hgetall('foo').should == {'key' => 'value', 'key1' => 'value1'}
+ @namespaced.hlen('foo').should == 2
+ @namespaced.hkeys('foo').should == ['key', 'key1']
+ end
+
it "should properly intersect three sets" do
@namespaced.sadd('foo', 1)
@namespaced.sadd('foo', 2)

0 comments on commit 241bdbf

Please sign in to comment.
Something went wrong with that request. Please try again.