Skip to content

Commit

Permalink
Add hash commands and test their usage
Browse files Browse the repository at this point in the history
  • Loading branch information
akahn authored and defunkt committed Mar 28, 2010
1 parent 191a104 commit 241bdbf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/redis/namespace.rb
Expand Up @@ -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" => [],
Expand Down
9 changes: 9 additions & 0 deletions spec/redis_spec.rb
Expand Up @@ -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)
Expand Down

0 comments on commit 241bdbf

Please sign in to comment.