anchor.diff:  -include("edis.hrl").
   
   -export([all/0,
  -         init/0, init_per_testcase/1, init_per_round/2,
  -         quit/0, quit_per_testcase/1, quit_per_round/2]).
  --export([hdel/1, hexists/1, hget/1, hgetall/1, hincrby/1, hkeys/1, hlen/1, hmget/1, hmset/1,
  -         hset/1, hsetnx/1, hvals/1]).
  +         init/1, init_per_testcase/2, init_per_round/3,
  +         quit/1, quit_per_testcase/2, quit_per_round/3]).
  +-export([hdel/2, hexists/2, hget/2, hgetall/2, hincrby/2, hkeys/2, hlen/2, hmget/2, hmset/2,
  +         hset/2, hsetnx/2, hvals/2]).
   
   %% ====================================================================
   %% External functions
  
positive.code:                                                 2 -> <<Key/binary, "__">>
                                                end, Key], result_type = boolean, group = hashes}).
  
  -spec hvals([binary()]) -> binary().
  hvals(_Keys) ->
    edis_db:run(
      edis_db:process(0),
      #edis_command{cmd = <<"HVALS">>, args = [?KEY], result_type = multi_bulk, group = hashes}).
negative.code: all() -> [Fun || {Fun, _} <- ?MODULE:module_info(exports) -- edis_bench:behaviour_info(callbacks),
                   Fun =/= module_info].
  
  -spec init([pos_integer()]) -> ok.
  init([Port]) ->
    case erldis:connect(localhost,16380) of
      {ok, Client} ->
        Name = process(Port),
        case erlang:whereis(Name) of
          undefined -> true;
          _ -> erlang:unregister(Name)
        end,
        erlang:register(Name, Client);
      Error -> throw(Error)
    end.
  
  -spec quit([pos_integer()]) -> ok.
  quit([Port]) ->
    Name = process(Port),
    case erlang:whereis(Name) of
      undefined -> true;
      Client ->
        erldis_client:stop(Client),
        erlang:unregister(Name)
    end,
    ok.
  
  -spec init_per_testcase(atom(), [pos_integer()]) -> ok.
  init_per_testcase(_Function, _Extra) -> ok.
  
  -spec quit_per_testcase(atom(), [pos_integer()]) -> ok.
  quit_per_testcase(_Function, _Extra) -> ok.
  
  -spec init_per_round(atom(), [binary()], [pos_integer()]) -> ok.
  init_per_round(incrby, Keys, [Port]) ->
    _ = erldis:hset(process(Port), ?KEY, ?KEY, edis_util:integer_to_binary(length(Keys))),
    ok;
  init_per_round(Fun, Keys, [Port]) when Fun =:= hgetall;
                                         Fun =:= hkeys;
                                         Fun =:= hvals;
                                         Fun =:= hlen ->
    erldis:hmset(process(Port), ?KEY, lists:flatmap(fun(Key) -> [Key, <<"x">>] end, Keys));
  init_per_round(Fun, _Keys, [Port]) when Fun =:= hmget; Fun =:= hmset ->
    erldis:hmset(process(Port),
                 ?KEY,
                 lists:flatmap(
                   fun(Key) -> [edis_util:integer_to_binary(Key), <<"x">>] end,
                   lists:seq(1, 5000)));
  init_per_round(_Fun, Keys, [Port]) ->
    erldis:hmset(process(Port),
                 ?KEY,
                 lists:flatmap(
                   fun(Key) -> [Key, <<"x">>, <<Key/binary, "-2">>, <<"y">>] end,
                   Keys)).
  
  -spec quit_per_round(atom(), [binary()], [pos_integer()]) -> ok.
  quit_per_round(_, _Keys, [Port]) ->
    _ = erldis:del(process(Port), ?KEY),
    ok.
  
  
  -spec hdel([binary()], pos_integer()) -> pos_integer().
  hdel(Keys, Port) ->
    edis_db:run(
      edis_db:process(0),
      #edis_command{cmd = <<"HDEL">>, args = [?KEY | Keys], group = hashes, result_type = number}).
  
  -spec hexists([binary(),...], pos_integer()) -> boolean().
  hexists([Key|_], Port) ->
    edis_db:run(
      edis_db:process(0),
      #edis_command{cmd = <<"HEXISTS">>, args = [?KEY, Key], result_type = boolean, group = hashes}).
  
  -spec hget([binary()], pos_integer()) -> binary().
  hget([Key|_], Port) ->
    edis_db:run(
      edis_db:process(0),
      #edis_command{cmd = <<"HGET">>, args = [?KEY, Key], result_type = bulk, group = hashes}).
  
  -spec hgetall([binary()], pos_integer()) -> binary().
  hgetall(_Keys, Port) ->
    edis_db:run(
      edis_db:process(0),
      #edis_command{cmd = <<"HGETALL">>, args = [?KEY], result_type = multi_bulk, group = hashes}).
  
  -spec hincrby([binary()], pos_integer()) -> integer().
  hincrby(Keys, Port) ->
    edis_db:run(
      edis_db:process(0),
      #edis_command{cmd = <<"HINCRBY">>, args = [?KEY, ?KEY, length(Keys)],
                    group = hashes, result_type = number}).
  
  -spec hkeys([binary()], pos_integer()) -> binary().
  hkeys(_Keys, Port) ->
    edis_db:run(
      edis_db:process(0),
      #edis_command{cmd = <<"HKEYS">>, args = [?KEY], result_type = multi_bulk, group = hashes}).
  
  -spec hlen([binary()], pos_integer()) -> binary().
  hlen(_Keys, Port) ->
    edis_db:run(
      edis_db:process(0),
      #edis_command{cmd = <<"HLEN">>, args = [?KEY], result_type = number, group = hashes}).
  
  -spec hmget([binary()], pos_integer()) -> binary().
  hmget(Keys, Port) ->
    edis_db:run(
      edis_db:process(0),
      #edis_command{cmd = <<"HMGET">>, args = [?KEY | Keys], result_type = multi_bulk, group = hashes}).
  
  -spec hmset([binary()], pos_integer()) -> binary().
  hmset(Keys, Port) ->
    edis_db:run(
      edis_db:process(0),
      #edis_command{cmd = <<"HMSET">>, args = [?KEY, [{Key, <<"y">>} || Key <- Keys]],
                    result_type = ok, group = hashes}).
  
  -spec hset([binary()], pos_integer()) -> binary().
  hset([Key|_], Port) ->
    edis_db:run(
      edis_db:process(0),
      #edis_command{cmd = <<"HSET">>, args = [?KEY, Key, Key], result_type = boolean, group = hashes}).
  
  -spec hsetnx([binary()], pos_integer()) -> binary().
  hsetnx([Key|_], Port) ->
    edis_db:run(
      edis_db:process(0),
      #edis_command{cmd = <<"HSETNX">>, args = [?KEY,
  