Current section
Files
Jump to
Current section
Files
src/radish@command@sorted_set.erl
-module(radish@command@sorted_set).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function]).
-export([add_new/2, upsert/2, upsert_only_lower_scores/2, upsert_only_higher_scores/2, update/2, update_only_lower_scores/2, update_only_higher_scores/2, incr_by/3, card/1, count/3, score/2, scan/3, scan_pattern/4, 'rem'/2, random_members/2, rank/2, reverse_rank/2, pop_min/2, pop_max/2]).
-spec add_new(binary(), list({binary(), binary()})) -> bitstring().
add_new(Key, Members) ->
_pipe = [<<"ZADD"/utf8>>, Key, <<"NX"/utf8>>, <<"CH"/utf8>>],
_pipe@1 = gleam@list:append(
_pipe,
gleam@list:map(
Members,
fun(Member) ->
<<(erlang:element(2, Member))/binary,
(erlang:element(1, Member))/binary>>
end
)
),
radish@utils:prepare(_pipe@1).
-spec upsert(binary(), list({binary(), binary()})) -> bitstring().
upsert(Key, Members) ->
_pipe = [<<"ZADD"/utf8>>, Key, <<"CH"/utf8>>],
_pipe@1 = gleam@list:append(
_pipe,
gleam@list:map(
Members,
fun(Member) ->
<<(erlang:element(2, Member))/binary,
(erlang:element(1, Member))/binary>>
end
)
),
radish@utils:prepare(_pipe@1).
-spec upsert_only_lower_scores(binary(), list({binary(), binary()})) -> bitstring().
upsert_only_lower_scores(Key, Members) ->
_pipe = [<<"ZADD"/utf8>>, Key, <<"LT"/utf8>>, <<"CH"/utf8>>],
_pipe@1 = gleam@list:append(
_pipe,
gleam@list:map(
Members,
fun(Member) ->
<<(erlang:element(2, Member))/binary,
(erlang:element(1, Member))/binary>>
end
)
),
radish@utils:prepare(_pipe@1).
-spec upsert_only_higher_scores(binary(), list({binary(), binary()})) -> bitstring().
upsert_only_higher_scores(Key, Members) ->
_pipe = [<<"ZADD"/utf8>>, Key, <<"GT"/utf8>>, <<"CH"/utf8>>],
_pipe@1 = gleam@list:append(
_pipe,
gleam@list:map(
Members,
fun(Member) ->
<<(erlang:element(2, Member))/binary,
(erlang:element(1, Member))/binary>>
end
)
),
radish@utils:prepare(_pipe@1).
-spec update(binary(), list({binary(), binary()})) -> bitstring().
update(Key, Members) ->
_pipe = [<<"ZADD"/utf8>>, Key, <<"XX"/utf8>>, <<"CH"/utf8>>],
_pipe@1 = gleam@list:append(
_pipe,
gleam@list:map(
Members,
fun(Member) ->
<<(erlang:element(2, Member))/binary,
(erlang:element(1, Member))/binary>>
end
)
),
radish@utils:prepare(_pipe@1).
-spec update_only_lower_scores(binary(), list({binary(), binary()})) -> bitstring().
update_only_lower_scores(Key, Members) ->
_pipe = [<<"ZADD"/utf8>>, Key, <<"XX"/utf8>>, <<"LT"/utf8>>, <<"CH"/utf8>>],
_pipe@1 = gleam@list:append(
_pipe,
gleam@list:map(
Members,
fun(Member) ->
<<(erlang:element(2, Member))/binary,
(erlang:element(1, Member))/binary>>
end
)
),
radish@utils:prepare(_pipe@1).
-spec update_only_higher_scores(binary(), list({binary(), binary()})) -> bitstring().
update_only_higher_scores(Key, Members) ->
_pipe = [<<"ZADD"/utf8>>, Key, <<"XX"/utf8>>, <<"GT"/utf8>>, <<"CH"/utf8>>],
_pipe@1 = gleam@list:append(
_pipe,
gleam@list:map(
Members,
fun(Member) ->
<<(erlang:element(2, Member))/binary,
(erlang:element(1, Member))/binary>>
end
)
),
radish@utils:prepare(_pipe@1).
-spec incr_by(binary(), binary(), binary()) -> bitstring().
incr_by(Key, Member, Change_in_score) ->
_pipe = [<<"ZINCRBY"/utf8>>, Key, Change_in_score, Member],
radish@utils:prepare(_pipe).
-spec card(binary()) -> bitstring().
card(Key) ->
_pipe = [<<"ZCARD"/utf8>>, Key],
radish@utils:prepare(_pipe).
-spec count(binary(), binary(), binary()) -> bitstring().
count(Key, Min, Max) ->
_pipe = [<<"ZCOUNT"/utf8>>, Key, Min, Max],
radish@utils:prepare(_pipe).
-spec score(binary(), binary()) -> bitstring().
score(Key, Member) ->
_pipe = [<<"ZSCORE"/utf8>>, Key, Member],
radish@utils:prepare(_pipe).
-spec scan(binary(), integer(), integer()) -> bitstring().
scan(Key, Cursor, Count) ->
_pipe = [<<"ZSCAN"/utf8>>,
Key,
gleam@int:to_string(Cursor),
<<"COUNT"/utf8>>,
gleam@int:to_string(Count)],
radish@utils:prepare(_pipe).
-spec scan_pattern(binary(), integer(), binary(), integer()) -> bitstring().
scan_pattern(Key, Cursor, Pattern, Count) ->
_pipe = [<<"ZSCAN"/utf8>>,
Key,
gleam@int:to_string(Cursor),
<<"MATCH"/utf8>>,
Pattern,
<<"COUNT"/utf8>>,
gleam@int:to_string(Count)],
radish@utils:prepare(_pipe).
-spec 'rem'(binary(), list(binary())) -> bitstring().
'rem'(Key, Members) ->
_pipe = [<<"ZREM"/utf8>>, Key],
_pipe@1 = gleam@list:append(_pipe, Members),
radish@utils:prepare(_pipe@1).
-spec random_members(binary(), integer()) -> bitstring().
random_members(Key, Count) ->
_pipe = [<<"ZRANDMEMBER"/utf8>>,
Key,
gleam@int:to_string(Count),
<<"WITHSCORES"/utf8>>],
radish@utils:prepare(_pipe).
-spec rank(binary(), binary()) -> bitstring().
rank(Key, Member) ->
_pipe = [<<"ZRANK"/utf8>>, Key, Member, <<"WITHSCORE"/utf8>>],
radish@utils:prepare(_pipe).
-spec reverse_rank(binary(), binary()) -> bitstring().
reverse_rank(Key, Member) ->
_pipe = [<<"ZREVRANK"/utf8>>, Key, Member, <<"WITHSCORE"/utf8>>],
radish@utils:prepare(_pipe).
-spec pop_min(binary(), integer()) -> bitstring().
pop_min(Key, Count) ->
_pipe = [<<"ZPOPMIN"/utf8>>, Key, gleam@int:to_string(Count)],
radish@utils:prepare(_pipe).
-spec pop_max(binary(), integer()) -> bitstring().
pop_max(Key, Count) ->
_pipe = [<<"ZPOPMAX"/utf8>>, Key, gleam@int:to_string(Count)],
radish@utils:prepare(_pipe).