}
ConvertToBool = lambda{|r| r == 0 ? false : r}
- ConvertToSet = lambda{|r| Set.new(r)}
ReplyProcessor = {
"exists" => ConvertToBool,
"del"=> ConvertToBool,
"renamenx"=> ConvertToBool,
"expire"=> ConvertToBool,
- "smembers" => ConvertToSet,
- "sinter" => ConvertToSet,
- "sunion" => ConvertToSet,
- "sdiff" => ConvertToSet,
"keys" => lambda{|r| r.split(" ")},
"info" => lambda{|r|
info = {}
else
sock = TCPSocket.new(host, port, 0)
end
+ sock.setsockopt Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1
# If the timeout is set we set the low level socket options in order
# to make sure a blocking read will return after the specified number
bulk = nil
argv[0] = argv[0].to_s.downcase
argv[0] = Aliases[argv[0]] if Aliases[argv[0]]
- if BulkCommands[argv[0]]
+ if BulkCommands[argv[0]] and argv.length > 1
bulk = argv[-1].to_s
argv[-1] = bulk.length
end
}
res
else
- raise "Protocol error, got '#{rtype}' as initial reply bye"
+ raise "Protocol error, got '#{rtype}' as initial reply byte"
end
end
end