Skip to content

Commit

Permalink
add socket nodelay true for edis
Browse files Browse the repository at this point in the history
  • Loading branch information
xinmingyao committed Jul 6, 2012
1 parent d4a3303 commit b8c47f4
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/edis_client.erl
Expand Up @@ -79,7 +79,7 @@ init([Socket,_Transport,_TransOps]) ->
end,
?INFO("New Client: ~p ~n", [PeerPort]),
% ok = inet:setopts(Socket, ?TCP_OPTIONS),
ok = inet:setopts(Socket, [{active, once}, {packet, line}, binary]),
ok = inet:setopts(Socket, [{active, once}, {nodelay, true},{packet, line}, binary]),
_ = erlang:process_flag(trap_exit, true), %% We want to know even if it stops normally
{ok, CmdRunner} = edis_command_runner:start_link(Socket),
{ok, command_start, #state{socket = Socket,
Expand Down
2 changes: 1 addition & 1 deletion src/edis_command_runner.erl
Expand Up @@ -180,7 +180,7 @@ parse_command(#edis_command{cmd = <<"DECR">>}) -> throw(bad_arg_num);
parse_command(C = #edis_command{cmd = <<"DECRBY">>, args = [Key, Decrement]}) ->
C#edis_command{args = [Key, edis_util:binary_to_integer(Decrement)],result_type = number, group=strings};
parse_command(#edis_command{cmd = <<"DECRBY">>}) -> throw(bad_arg_num);
parse_command(C = #edis_command{cmd = <<"GET">>, args = [_Key]}) -> C#edis_command{result_type = string, group=strings};%%todo fix
parse_command(C = #edis_command{cmd = <<"GET">>, args = [_Key]}) -> C#edis_command{result_type = bulk, group=strings};
parse_command(#edis_command{cmd = <<"GET">>}) -> throw(bad_arg_num);
parse_command(C = #edis_command{cmd = <<"GETBIT">>, args = [Key, Offset]}) ->
try edis_util:binary_to_integer(Offset) of
Expand Down
1 change: 1 addition & 0 deletions src/edis_db.erl
Expand Up @@ -121,6 +121,7 @@ Reply =
#edis_item{type = string, value = Value}=V2
, {ok, Value}
end,
?INFO("~p",[Reply]),
{reply, Reply, stamp(Key, read, State)};


Expand Down
2 changes: 1 addition & 1 deletion src/tiger_kv_app.erl
Expand Up @@ -15,7 +15,7 @@ start(_StartType, _StartArgs) ->
{ok,RedisIp}=tiger_kv_util:get_env(redis_ip,"127.0.0.1"),
{ok,RedisPort}=tiger_kv_util:get_env(redis_port,6379),
{ok,_}=cowboy:start_listener(memcached,100,cowboy_tcp_transport,[{port,MemPort}],memcached_frontend,[]),
{ok,_}=cowboy:start_listener(redis,100,cowboy_tcp_transport,[{port,RedisPort}],edis_client,[]),
{ok,_}=cowboy:start_listener(redis,100,cowboy_tcp_transport,[{port,RedisPort}, {nodelay, true}],edis_client,[]),
tiger_kv_sup:start_link()
.

Expand Down

0 comments on commit b8c47f4

Please sign in to comment.