+ ConvertToBool = lambda{|r| r == 0 ? false : r}
+ ConvertToSet = lambda{|r| Set.new(r)}
+
+ ReplyProcessor = {
+ "exists" => ConvertToBool,
+ "sismember"=> ConvertToBool,
+ "sadd"=> ConvertToBool,
+ "srem"=> ConvertToBool,
+ "smove"=> ConvertToBool,
+ "move"=> ConvertToBool,
+ "setnx"=> ConvertToBool,
+ "del"=> ConvertToBool,
+ "renamenx"=> ConvertToBool,
+ "expire"=> ConvertToBool,
+ "smembers" => ConvertToSet,
+ "sinter" => ConvertToSet,
+ "sunion" => ConvertToSet,
+ "sdiff" => ConvertToSet,
+ "keys" => lambda{|r| r.split(" ")},
+ "info" => lambda{|r|
+ info = {}
+ r.each_line {|kv|
+ k,v = kv.split(":",2).map{|x| x.chomp}
+ info[k.to_sym] = v
+ }
+ info
+ }
+ }
+
+ Aliases = {
+ "flush_db" => "flushdb",
+ "flush_all" => "flushall",
+ "last_save" => "lastsave",
+ "key?" => "exists",
+ "delete" => "del",
+ "randkey" => "randomkey",
+ "list_length" => "llen",
+ "push_tail" => "rpush",
+ "push_head" => "lpush",
+ "pop_tail" => "rpop",
+ "pop_head" => "lpop",
+ "list_set" => "lset",
+ "list_range" => "lrange",
+ "list_trim" => "ltrim",
+ "list_index" => "lindex",
+ "list_rm" => "lrem",
+ "set_add" => "sadd",
+ "set_delete" => "srem",
+ "set_count" => "scard",
+ "set_member?" => "sismember",
+ "set_members" => "smembers",
+ "set_intersect" => "sinter",
+ "set_intersect_store" => "sinterstore",
+ "set_inter_store" => "sinterstore",
+ "set_union" => "sunion",
+ "set_union_store" => "sunionstore",
+ "set_diff" => "sdiff",
+ "set_diff_store" => "sdiffstore",
+ "set_move" => "smove",
+ "set_unless_exists" => "setnx",
+ "rename_unless_exists" => "renamenx"
+ }
+