Current section

Files

Jump to
radish src radish@set.erl
Raw

src/radish@set.erl

-module(radish@set).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([add/4, card/3, is_member/4, members/3, scan/5, scan_pattern/6]).
-file("/home/massivefermion/Desktop/radish/src/radish/set.gleam", 14).
-spec add(
lifeguard:pool(radish@client:message()),
binary(),
list(binary()),
integer()
) -> {ok, integer()} | {error, radish@error:error()}.
add(Client, Key, Values, Timeout) ->
_pipe = radish@command@set:add(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).
-file("/home/massivefermion/Desktop/radish/src/radish/set.gleam", 27).
-spec card(lifeguard:pool(radish@client:message()), binary(), integer()) -> {ok,
integer()} |
{error, radish@error:error()}.
card(Client, Key, Timeout) ->
_pipe = radish@command@set:card(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).
-file("/home/massivefermion/Desktop/radish/src/radish/set.gleam", 40).
-spec is_member(
lifeguard:pool(radish@client:message()),
binary(),
binary(),
integer()
) -> {ok, integer()} | {error, radish@error:error()}.
is_member(Client, Key, Value, Timeout) ->
_pipe = radish@command@set:is_member(Key, 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).
-file("/home/massivefermion/Desktop/radish/src/radish/set.gleam", 53).
-spec members(lifeguard:pool(radish@client:message()), binary(), integer()) -> {ok,
gleam@set:set(binary())} |
{error, radish@error:error()}.
members(Client, Key, Timeout) ->
_pipe = radish@command@set:members(Key),
_pipe@1 = radish@utils:execute(Client, _pipe, Timeout),
_pipe@4 = gleam@result:map(_pipe@1, fun(Value) -> case Value of
[{set, Set}] ->
gleam@result:then(
begin
_pipe@2 = Set,
_pipe@3 = gleam@set:to_list(_pipe@2),
gleam@list:try_map(
_pipe@3,
fun(Item) -> case Item of
{bulk_string, Str} ->
{ok, Str};
_ ->
{error, resp_error}
end end
)
end,
fun(List) -> {ok, gleam@set:from_list(List)} end
);
_ ->
{error, resp_error}
end end),
gleam@result:flatten(_pipe@4).
-file("/home/massivefermion/Desktop/radish/src/radish/set.gleam", 78).
-spec scan(
lifeguard:pool(radish@client:message()),
binary(),
integer(),
integer(),
integer()
) -> {ok, {list(binary()), integer()}} | {error, radish@error:error()}.
scan(Client, Key, Cursor, Count, Timeout) ->
_pipe = radish@command@set:scan(Key, Cursor, Count),
_pipe@1 = radish@utils:execute(Client, _pipe, Timeout),
_pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of
[{array, [{bulk_string, New_cursor_str}, {array, Keys}]}] ->
case gleam_stdlib:parse_int(New_cursor_str) of
{ok, New_cursor} ->
gleam@result:then(
gleam@list:try_map(
Keys,
fun(Item) -> case Item of
{bulk_string, Value@1} ->
{ok, Value@1};
_ ->
{error, resp_error}
end end
),
fun(Array) -> {ok, {Array, New_cursor}} end
);
{error, nil} ->
{error, resp_error}
end;
_ ->
{error, resp_error}
end end),
gleam@result:flatten(_pipe@2).
-file("/home/massivefermion/Desktop/radish/src/radish/set.gleam", 105).
-spec scan_pattern(
lifeguard:pool(radish@client:message()),
binary(),
integer(),
binary(),
integer(),
integer()
) -> {ok, {list(binary()), integer()}} | {error, radish@error:error()}.
scan_pattern(Client, Key, Cursor, Pattern, Count, Timeout) ->
_pipe = radish@command@set:scan_pattern(Key, Cursor, Pattern, Count),
_pipe@1 = radish@utils:execute(Client, _pipe, Timeout),
_pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of
[{array, [{bulk_string, New_cursor_str}, {array, Keys}]}] ->
case gleam_stdlib:parse_int(New_cursor_str) of
{ok, New_cursor} ->
gleam@result:then(
gleam@list:try_map(
Keys,
fun(Item) -> case Item of
{bulk_string, Value@1} ->
{ok, Value@1};
_ ->
{error, resp_error}
end end
),
fun(Array) -> {ok, {Array, New_cursor}} end
);
{error, nil} ->
{error, resp_error}
end;
_ ->
{error, resp_error}
end end),
gleam@result:flatten(_pipe@2).