Skip to content

Commit

Permalink
HGET/HSET support with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qrush committed Mar 23, 2010
1 parent c39b02e commit 3937ef2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/redis/client.rb
Expand Up @@ -52,6 +52,7 @@ class Client
"del" => BOOLEAN_PROCESSOR,
"renamenx" => BOOLEAN_PROCESSOR,
"expire" => BOOLEAN_PROCESSOR,
"hset" => BOOLEAN_PROCESSOR,
"info" => lambda{|r|
info = {}
r.each_line {|kv|
Expand Down Expand Up @@ -245,7 +246,7 @@ def raw_call_command(argvp)
def process_command(command, argvv)
@sock.write(command)
argvv.map do |argv|
processor = REPLY_PROCESSOR[argv[0]]
processor = REPLY_PROCESSOR[argv[0].to_s]
processor ? processor.call(read_reply) : read_reply
end
end
Expand Down Expand Up @@ -275,7 +276,7 @@ def set(key, value, expiry=nil)
expire(key, expiry) if s && expiry
s
end

def mset(*args)
hsh = args.pop if Hash === args.last
if hsh
Expand All @@ -284,7 +285,7 @@ def mset(*args)
call_command(args.unshift(:mset))
end
end

def msetnx(*args)
hsh = args.pop if Hash === args.last
if hsh
Expand Down
4 changes: 4 additions & 0 deletions spec/redis_spec.rb
Expand Up @@ -710,4 +710,8 @@ def ==(other)
@r.get("key1").should == "value1"
end

it "can set and get hash values" do
@r.hset("rush", "signals", "1982").should == true
@r.hget("rush", "signals").should == "1982"
end
end

0 comments on commit 3937ef2

Please sign in to comment.