diff --git a/src/mero.erl b/src/mero.erl index be23713..c09060b 100644 --- a/src/mero.erl +++ b/src/mero.erl @@ -147,7 +147,7 @@ mgets(ClusterName, Keys) -> ok | {error, Reason :: term()}. add(ClusterName, Key, Value, ExpTime, Timeout) when is_atom(ClusterName), is_binary(Value), is_integer(ExpTime) -> - BExpTime = list_to_binary(integer_to_list(ExpTime)), + BExpTime = integer_to_binary(ExpTime), mero_conn:add(ClusterName, Key, Value, BExpTime, Timeout). -spec madd(ClusterName :: atom(), @@ -155,7 +155,7 @@ add(ClusterName, Key, Value, ExpTime, Timeout) Timeout :: integer()) -> [ok | {error, Reason :: term()}]. madd(ClusterName, KVEs, Timeout) when is_atom(ClusterName) -> - L = [{Key, Value, list_to_binary(integer_to_list(ExpTime))} + L = [{Key, Value, integer_to_binary(ExpTime)} || {Key, Value, ExpTime} <- KVEs, is_binary(Key), is_binary(Value), is_integer(ExpTime)], mero_conn:madd(ClusterName, L, Timeout). @@ -191,7 +191,7 @@ mset(ClusterName, KVEs, Timeout) -> cas(ClusterName, Key, Value, ExpTime, Timeout, CAS) when is_atom(ClusterName), is_binary(Value), is_integer(ExpTime) -> - BExpTime = list_to_binary(integer_to_list(ExpTime)), + BExpTime = integer_to_binary(ExpTime), %% note: if CAS is undefined, this will be an unconditional set: mero_conn:set(ClusterName, Key, Value, BExpTime, Timeout, CAS). @@ -203,7 +203,7 @@ cas(ClusterName, Key, Value, ExpTime, Timeout, CAS) mcas(ClusterName, KVECs, Timeout) when is_atom(ClusterName) -> %% note: if CAS is undefined, the corresponding set will be unconditional. - L = [{Key, Value, list_to_binary(integer_to_list(ExpTime)), CAS} + L = [{Key, Value, integer_to_binary(ExpTime), CAS} || {Key, Value, ExpTime, CAS} <- KVECs, is_binary(Key), is_binary(Value), @@ -234,9 +234,9 @@ increment_counter(ClusterName, Key) when is_atom(ClusterName) -> increment_counter(ClusterName, Key, Value, Initial, ExpTime, Retries, Timeout) when is_integer(Value), is_integer(ExpTime), is_atom(ClusterName), Initial >= 0, Value >= 0 -> - BValue = list_to_binary(integer_to_list(Value)), - BInitial = list_to_binary(integer_to_list(Initial)), - BExpTime = list_to_binary(integer_to_list(ExpTime)), + BValue = integer_to_binary(Value), + BInitial = integer_to_binary(Initial), + BExpTime = integer_to_binary(ExpTime), mero_conn:increment_counter(ClusterName, Key, BValue, @@ -265,9 +265,9 @@ mincrement_counter(ClusterName, Keys) when is_atom(ClusterName), is_list(Keys) - mincrement_counter(ClusterName, Keys, Value, Initial, ExpTime, Timeout) when is_list(Keys), is_integer(Value), is_integer(ExpTime), is_atom(ClusterName), Initial >= 0, Value >= 0 -> - BValue = list_to_binary(integer_to_list(Value)), - BInitial = list_to_binary(integer_to_list(Initial)), - BExpTime = list_to_binary(integer_to_list(ExpTime)), + BValue = integer_to_binary(Value), + BInitial = integer_to_binary(Initial), + BExpTime = integer_to_binary(ExpTime), mero_conn:mincrement_counter(ClusterName, Keys, BValue, BInitial, BExpTime, Timeout). -spec delete(ClusterName :: atom(), Key :: mero_key(), Timeout :: integer()) -> diff --git a/src/mero_util.erl b/src/mero_util.erl index 3fa26d5..8f5e193 100644 --- a/src/mero_util.erl +++ b/src/mero_util.erl @@ -20,7 +20,7 @@ to_int(Value) when is_binary(Value) -> to_bin(Value) when is_binary(Value) -> Value; to_bin(Value) when is_integer(Value) -> - to_bin(integer_to_list(Value)); + integer_to_binary(Value); to_bin(Value) when is_list(Value) -> list_to_binary(Value). diff --git a/src/mero_wrk_tcp_txt.erl b/src/mero_wrk_tcp_txt.erl index b0351a8..dee6a07 100755 --- a/src/mero_wrk_tcp_txt.erl +++ b/src/mero_wrk_tcp_txt.erl @@ -209,7 +209,7 @@ pack({?MEMCACHE_DELETE, {Key}}) when is_binary(Key) -> pack({?MEMCACHE_DELETEQ, {Key}}) when is_binary(Key) -> [<<"delete ">>, Key, <<" noreply ">>, <<"\r\n">>]; pack({?MEMCACHE_ADD, {Key, Initial, ExpTime}}) -> - NBytes = integer_to_list(size(Initial)), + NBytes = integer_to_binary(size(Initial)), [<<"add ">>, Key, <<" ">>, @@ -222,7 +222,7 @@ pack({?MEMCACHE_ADD, {Key, Initial, ExpTime}}) -> Initial, <<"\r\n">>]; pack({?MEMCACHE_SET, {Key, Initial, ExpTime, undefined}}) -> - NBytes = integer_to_list(size(Initial)), + NBytes = integer_to_binary(size(Initial)), [<<"set ">>, Key, <<" ">>, @@ -238,7 +238,7 @@ pack({?MEMCACHE_SET, {Key, Initial, ExpTime, CAS}}) when is_integer(CAS) -> %% note: CAS should only be supplied if setting a value after looking it up. if the %% value has changed since we looked it up, the result of a cas command will be EXISTS %% (otherwise STORED). - NBytes = integer_to_list(size(Initial)), + NBytes = integer_to_binary(size(Initial)), [<<"cas ">>, Key, <<" ">>,