|
@@ -28,10 +28,10 @@
|
|
|
%% @type socket() = {socket, port()}. Tuple describing an existing socket
|
|
|
%% @type memcached_connection() = hostport() | socket().
|
|
|
%% @type memcached_key() = list() | atom().
|
|
|
--type(hostport() :: {host, string(), port, integer()}).
|
|
|
--type(socket() :: {socket, port()}).
|
|
|
--type(memcached_connection() :: hostport() | socket()).
|
|
|
--type(memcached_key() :: list() | atom()).
|
|
|
+%%-type(hostport() :: {host, string(), port, integer()}).
|
|
|
+%%-type(socket() :: {socket, port()}).
|
|
|
+%%-type(memcached_connection() :: hostport() | socket()).
|
|
|
+%%-type(memcached_key() :: list() | atom()).
|
|
|
|
|
|
|
|
|
%%====================================================================
|
|
@@ -40,8 +40,8 @@
|
|
|
%% @doc Associate Bytes with Key.
|
|
|
%% @spec set(memcached_connection(), Key::memcached_key(), Bytes::any()) ->
|
|
|
%% ok | {error, not_stored}
|
|
|
--spec(set/3::(memcached_connection(), memcached_key(), any()) ->
|
|
|
- ok | {error, not_stored}).
|
|
|
+%%-spec(set/3::(memcached_connection(), memcached_key(), any()) ->
|
|
|
+%% ok | {error, not_stored}).
|
|
|
set({host, Host, port, Port}, Key, Bytes) ->
|
|
|
set({host, Host, port, Port}, Key, 0, 0, Bytes);
|
|
|
set({socket, Socket}, Key, Bytes) ->
|
|
@@ -50,8 +50,8 @@ set({socket, Socket}, Key, Bytes) ->
|
|
|
%% @doc Associate Bytes with Key using Flags and Expire options.
|
|
|
%% @spec set(memcached_connection(), Key::memcached_key(), Flags::integer(), Expire::integer(), Bytes::any()) ->
|
|
|
%% ok | {error, not_stored}
|
|
|
--spec(set/5::(memcached_connection(), memcached_key(), integer(), integer(), any()) ->
|
|
|
- ok | {error, not_stored}).
|
|
|
+%%-spec(set/5::(memcached_connection(), memcached_key(), integer(), integer(), any()) ->
|
|
|
+%% ok | {error, not_stored}).
|
|
|
set({host, Host, port, Port}, Key, Flags, Expire, Bytes) ->
|
|
|
{ok, Socket} = gen_tcp:connect(Host, Port, [binary, {active, false}]),
|
|
|
Reply = process_set(Socket, set, Key, Flags, Expire, Bytes),
|
|
@@ -65,8 +65,8 @@ set({socket, Socket}, Key, Flags, Expire, Bytes) ->
|
|
|
%% @doc Associate Bytes with Key if Key isn't set already in memcached.
|
|
|
%% @spec add(memcached_connection(), Key::memcached_key(), Bytes::any()) ->
|
|
|
%% ok | {error, not_stored}
|
|
|
--spec(add/3::(memcached_connection(), memcached_key(), any()) ->
|
|
|
- ok | {error, not_stored}).
|
|
|
+%%-spec(add/3::(memcached_connection(), memcached_key(), any()) ->
|
|
|
+%% ok | {error, not_stored}).
|
|
|
add({host, Host, port, Port}, Key, Bytes) ->
|
|
|
add({host, Host, port, Port}, Key, 0, 0, Bytes);
|
|
|
add({socket, Socket}, Key, Bytes) ->
|
|
@@ -75,8 +75,8 @@ add({socket, Socket}, Key, Bytes) ->
|
|
|
%% @doc Associate Bytes with Key using Flags and Expire options if Key isn't set already in memcached.
|
|
|
%% @spec add(memcached_connection(), Key::memcached_key(), Flags::integer(), Expire::integer(), Bytes::any()) ->
|
|
|
%% ok | {error, not_stored}
|
|
|
--spec(add/5::(memcached_connection(), memcached_key(), integer(), integer(), any()) ->
|
|
|
- ok | {error, not_stored}).
|
|
|
+%%-spec(add/5::(memcached_connection(), memcached_key(), integer(), integer(), any()) ->
|
|
|
+%% ok | {error, not_stored}).
|
|
|
add({host, Host, port, Port}, Key, Flags, Expire, Bytes) ->
|
|
|
{ok, Socket} = gen_tcp:connect(Host, Port, [binary, {active, false}]),
|
|
|
Reply = process_set(Socket, add, Key, Flags, Expire, Bytes),
|
|
@@ -90,8 +90,8 @@ add({socket, Socket}, Key, Flags, Expire, Bytes) ->
|
|
|
%% @doc Associate Bytes with Key if Key is set already in memcached.
|
|
|
%% @spec replace(memcached_connection(), Key::memcached_key(), Bytes::any()) ->
|
|
|
%% ok | {error, not_stored}
|
|
|
--spec(replace/3::(memcached_connection(), memcached_key(), any()) ->
|
|
|
- ok | {error, not_stored}).
|
|
|
+%%-spec(replace/3::(memcached_connection(), memcached_key(), any()) ->
|
|
|
+%% ok | {error, not_stored}).
|
|
|
replace({host, Host, port, Port}, Key, Bytes) ->
|
|
|
replace({host, Host, port, Port}, Key, 0, 0, Bytes);
|
|
|
replace({socket, Socket}, Key, Bytes) ->
|
|
@@ -100,8 +100,8 @@ replace({socket, Socket}, Key, Bytes) ->
|
|
|
%% @doc Associate Bytes with Key using Flags and Expire options if Key is set already in memcached.
|
|
|
%% @spec replace(memcached_connection(), Key::memcached_key(), Flags::integer(), Expire::integer(), Bytes::any()) ->
|
|
|
%% ok | {error, not_stored}
|
|
|
--spec(replace/5::(memcached_connection(), memcached_key(), integer(), integer(), any()) ->
|
|
|
- ok | {error, not_stored}).
|
|
|
+%%-spec(replace/5::(memcached_connection(), memcached_key(), integer(), integer(), any()) ->
|
|
|
+%% ok | {error, not_stored}).
|
|
|
replace({host, Host, port, Port}, Key, Flags, Expire, Bytes) ->
|
|
|
{ok, Socket} = gen_tcp:connect(Host, Port, [binary, {active, false}]),
|
|
|
Reply = process_set(Socket, replace, Key, Flags, Expire, Bytes),
|
|
@@ -117,8 +117,8 @@ replace({socket, Socket}, Key, Flags, Expire, Bytes) ->
|
|
|
%% keys.
|
|
|
%% @spec get(memcached_connection(), Key::memcached_key() | [Key::memcached_key()]) ->
|
|
|
%% [any()]
|
|
|
--spec(get/2::(memcached_connection(), memcached_key() | [memcached_key()]) ->
|
|
|
- [any()]).
|
|
|
+%%-spec(get/2::(memcached_connection(), memcached_key() | [memcached_key()]) ->
|
|
|
+%% [any()]).
|
|
|
get({host, Host, port, Port}, [Head|Tail]) when is_list(Head) ->
|
|
|
{ok, Socket} = gen_tcp:connect(Host, Port, [binary, {active, false}]),
|
|
|
Reply = process_get(Socket, [Head] ++ Tail),
|
|
@@ -140,8 +140,8 @@ get({socket, Socket}, Key) ->
|
|
|
%% @doc Delete a key from memcached
|
|
|
%% @spec delete(memcached_connection(), Key::memcached_key()) ->
|
|
|
%% ok | {error, not_found}
|
|
|
--spec(delete/2::(memcached_connection(), memcached_key()) ->
|
|
|
- ok | {error, not_found}).
|
|
|
+%%-spec(delete/2::(memcached_connection(), memcached_key()) ->
|
|
|
+%% ok | {error, not_found}).
|
|
|
delete({host, Host, port, Port}, Key) ->
|
|
|
delete({host, Host, port, Port}, Key, 0);
|
|
|
delete({socket, Socket}, Key) ->
|
|
@@ -150,8 +150,8 @@ delete({socket, Socket}, Key) ->
|
|
|
%% @doc Delete a key from memcached after Time seconds
|
|
|
%% @spec delete(memcached_connection(), Key::memcached_key(), Time::integer()) ->
|
|
|
%% ok | {error, not_found}
|
|
|
--spec(delete/3::(memcached_connection(), memcached_key(), integer()) ->
|
|
|
- ok | {error, not_found}).
|
|
|
+%%-spec(delete/3::(memcached_connection(), memcached_key(), integer()) ->
|
|
|
+%% ok | {error, not_found}).
|
|
|
delete({host, Host, port, Port}, Key, Time) ->
|
|
|
{ok, Socket} = gen_tcp:connect(Host, Port, [binary, {active, false}]),
|
|
|
Reply = process_delete(Socket, Key, Time),
|
|
@@ -165,8 +165,8 @@ delete({socket, Socket}, Key, Time) ->
|
|
|
%% @doc Delete a key from memcached
|
|
|
%% @spec stats(memcached_connection()) ->
|
|
|
%% [string()]
|
|
|
--spec(stats/1::(memcached_connection()) ->
|
|
|
- [string()]).
|
|
|
+%%-spec(stats/1::(memcached_connection()) ->
|
|
|
+%% [string()]).
|
|
|
stats({host, Host, port, Port}) ->
|
|
|
{ok, Socket} = gen_tcp:connect(Host, Port, [binary, {active, false}]),
|
|
|
Reply = process_stats(Socket),
|