Current section

Files

Jump to
radish src radish@list.erl
Raw

src/radish@list.erl

-module(radish@list).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function]).
-export([lpush/4, rpush/4, lpushx/4, rpushx/4, llen/3, lrange/5, lpop/3, rpop/3, lpop_multiple/4, rpop_multiple/4, lindex/4, lrem/5, lset/5, linsert_after/5, linsert_before/5]).
-spec lpush(
gleam@erlang@process:subject(radish@client:message()),
binary(),
list(binary()),
integer()
) -> {ok, integer()} | {error, radish@error:error()}.
lpush(Client, Key, Values, Timeout) ->
_pipe = radish@command@list:lpush(Key, Values),
_pipe@1 = radish@utils:execute(Client, _pipe, Timeout),
_pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of
{integer, N} ->
{ok, N};
_ ->
{error, resp_error}
end end),
gleam@result:flatten(_pipe@2).
-spec rpush(
gleam@erlang@process:subject(radish@client:message()),
binary(),
list(binary()),
integer()
) -> {ok, integer()} | {error, radish@error:error()}.
rpush(Client, Key, Values, Timeout) ->
_pipe = radish@command@list:rpush(Key, Values),
_pipe@1 = radish@utils:execute(Client, _pipe, Timeout),
_pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of
{integer, N} ->
{ok, N};
_ ->
{error, resp_error}
end end),
gleam@result:flatten(_pipe@2).
-spec lpushx(
gleam@erlang@process:subject(radish@client:message()),
binary(),
list(binary()),
integer()
) -> {ok, integer()} | {error, radish@error:error()}.
lpushx(Client, Key, Values, Timeout) ->
_pipe = radish@command@list:lpushx(Key, Values),
_pipe@1 = radish@utils:execute(Client, _pipe, Timeout),
_pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of
{integer, N} ->
{ok, N};
_ ->
{error, resp_error}
end end),
gleam@result:flatten(_pipe@2).
-spec rpushx(
gleam@erlang@process:subject(radish@client:message()),
binary(),
list(binary()),
integer()
) -> {ok, integer()} | {error, radish@error:error()}.
rpushx(Client, Key, Values, Timeout) ->
_pipe = radish@command@list:rpushx(Key, Values),
_pipe@1 = radish@utils:execute(Client, _pipe, Timeout),
_pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of
{integer, N} ->
{ok, N};
_ ->
{error, resp_error}
end end),
gleam@result:flatten(_pipe@2).
-spec llen(
gleam@erlang@process:subject(radish@client:message()),
binary(),
integer()
) -> {ok, integer()} | {error, radish@error:error()}.
llen(Client, Key, Timeout) ->
_pipe = radish@command@list:llen(Key),
_pipe@1 = radish@utils:execute(Client, _pipe, Timeout),
_pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of
{integer, N} ->
{ok, N};
_ ->
{error, resp_error}
end end),
gleam@result:flatten(_pipe@2).
-spec lrange(
gleam@erlang@process:subject(radish@client:message()),
binary(),
integer(),
integer(),
integer()
) -> {ok, list(binary())} | {error, radish@error:error()}.
lrange(Client, Key, Start, End, Timeout) ->
_pipe = radish@command@list:lrange(Key, Start, End),
_pipe@1 = radish@utils:execute(Client, _pipe, Timeout),
_pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of
{array, Array} ->
gleam@list:try_map(Array, fun(Item) -> case Item of
{bulk_string, Str} ->
{ok, Str};
_ ->
{error, resp_error}
end end);
_ ->
{error, resp_error}
end end),
gleam@result:flatten(_pipe@2).
-spec lpop(
gleam@erlang@process:subject(radish@client:message()),
binary(),
integer()
) -> {ok, binary()} | {error, radish@error:error()}.
lpop(Client, Key, Timeout) ->
_pipe = radish@command@list:lpop(Key, none),
_pipe@1 = radish@utils:execute(Client, _pipe, Timeout),
_pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of
{bulk_string, Str} ->
{ok, Str};
_ ->
{error, resp_error}
end end),
gleam@result:flatten(_pipe@2).
-spec rpop(
gleam@erlang@process:subject(radish@client:message()),
binary(),
integer()
) -> {ok, binary()} | {error, radish@error:error()}.
rpop(Client, Key, Timeout) ->
_pipe = radish@command@list:rpop(Key, none),
_pipe@1 = radish@utils:execute(Client, _pipe, Timeout),
_pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of
{bulk_string, Str} ->
{ok, Str};
_ ->
{error, resp_error}
end end),
gleam@result:flatten(_pipe@2).
-spec lpop_multiple(
gleam@erlang@process:subject(radish@client:message()),
binary(),
integer(),
integer()
) -> {ok, list(binary())} | {error, radish@error:error()}.
lpop_multiple(Client, Key, Count, Timeout) ->
_pipe = radish@command@list:lpop(Key, {some, Count}),
_pipe@1 = radish@utils:execute(Client, _pipe, Timeout),
_pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of
{array, Array} ->
gleam@list:try_map(Array, fun(Item) -> case Item of
{bulk_string, Str} ->
{ok, Str};
_ ->
{error, resp_error}
end end);
_ ->
{error, resp_error}
end end),
gleam@result:flatten(_pipe@2).
-spec rpop_multiple(
gleam@erlang@process:subject(radish@client:message()),
binary(),
integer(),
integer()
) -> {ok, list(binary())} | {error, radish@error:error()}.
rpop_multiple(Client, Key, Count, Timeout) ->
_pipe = radish@command@list:rpop(Key, {some, Count}),
_pipe@1 = radish@utils:execute(Client, _pipe, Timeout),
_pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of
{array, Array} ->
gleam@list:try_map(Array, fun(Item) -> case Item of
{bulk_string, Str} ->
{ok, Str};
_ ->
{error, resp_error}
end end);
_ ->
{error, resp_error}
end end),
gleam@result:flatten(_pipe@2).
-spec lindex(
gleam@erlang@process:subject(radish@client:message()),
binary(),
integer(),
integer()
) -> {ok, integer()} | {error, radish@error:error()}.
lindex(Client, Key, Index, Timeout) ->
_pipe = radish@command@list:lindex(Key, Index),
_pipe@1 = radish@utils:execute(Client, _pipe, Timeout),
_pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of
{integer, N} ->
{ok, N};
_ ->
{error, resp_error}
end end),
gleam@result:flatten(_pipe@2).
-spec lrem(
gleam@erlang@process:subject(radish@client:message()),
binary(),
integer(),
binary(),
integer()
) -> {ok, integer()} | {error, radish@error:error()}.
lrem(Client, Key, Count, Value, Timeout) ->
_pipe = radish@command@list:lrem(Key, Count, Value),
_pipe@1 = radish@utils:execute(Client, _pipe, Timeout),
_pipe@2 = gleam@result:map(_pipe@1, fun(Value@1) -> case Value@1 of
{integer, N} ->
{ok, N};
_ ->
{error, resp_error}
end end),
gleam@result:flatten(_pipe@2).
-spec lset(
gleam@erlang@process:subject(radish@client:message()),
binary(),
integer(),
binary(),
integer()
) -> {ok, binary()} | {error, radish@error:error()}.
lset(Client, Key, Index, Value, Timeout) ->
_pipe = radish@command@list:lset(Key, Index, Value),
_pipe@1 = radish@utils:execute(Client, _pipe, Timeout),
_pipe@2 = gleam@result:map(_pipe@1, fun(Value@1) -> case Value@1 of
{simple_string, Str} ->
{ok, Str};
_ ->
{error, resp_error}
end end),
gleam@result:flatten(_pipe@2).
-spec linsert_after(
gleam@erlang@process:subject(radish@client:message()),
binary(),
binary(),
binary(),
integer()
) -> {ok, integer()} | {error, radish@error:error()}.
linsert_after(Client, Key, Pivot, Value, Timeout) ->
_pipe = radish@command@list:linsert_after(Key, Pivot, Value),
_pipe@1 = radish@utils:execute(Client, _pipe, Timeout),
_pipe@2 = gleam@result:map(_pipe@1, fun(Value@1) -> case Value@1 of
{integer, N} ->
{ok, N};
_ ->
{error, resp_error}
end end),
gleam@result:flatten(_pipe@2).
-spec linsert_before(
gleam@erlang@process:subject(radish@client:message()),
binary(),
binary(),
binary(),
integer()
) -> {ok, integer()} | {error, radish@error:error()}.
linsert_before(Client, Key, Pivot, Value, Timeout) ->
_pipe = radish@command@list:linsert_before(Key, Pivot, Value),
_pipe@1 = radish@utils:execute(Client, _pipe, Timeout),
_pipe@2 = gleam@result:map(_pipe@1, fun(Value@1) -> case Value@1 of
{integer, N} ->
{ok, N};
_ ->
{error, resp_error}
end end),
gleam@result:flatten(_pipe@2).