Current section
Files
Jump to
Current section
Files
src/radish@command@list.erl
-module(radish@command@list).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function]).
-export([lpush/2, rpush/2, lpushx/2, rpushx/2, llen/1, lrange/3, lpop/2, rpop/2]).
-spec lpush(binary(), list(binary())) -> bitstring().
lpush(Key, Values) ->
_pipe = [<<"LPUSH"/utf8>>, Key],
_pipe@1 = gleam@list:append(
_pipe,
gleam@list:map(Values, fun(Value) -> Value end)
),
radish@utils:prepare(_pipe@1).
-spec rpush(binary(), list(binary())) -> bitstring().
rpush(Key, Values) ->
_pipe = [<<"RPUSH"/utf8>>, Key],
_pipe@1 = gleam@list:append(
_pipe,
gleam@list:map(Values, fun(Value) -> Value end)
),
radish@utils:prepare(_pipe@1).
-spec lpushx(binary(), list(binary())) -> bitstring().
lpushx(Key, Values) ->
_pipe = [<<"LPUSHX"/utf8>>, Key],
_pipe@1 = gleam@list:append(
_pipe,
gleam@list:map(Values, fun(Value) -> Value end)
),
radish@utils:prepare(_pipe@1).
-spec rpushx(binary(), list(binary())) -> bitstring().
rpushx(Key, Values) ->
_pipe = [<<"RPUSHX"/utf8>>, Key],
_pipe@1 = gleam@list:append(
_pipe,
gleam@list:map(Values, fun(Value) -> Value end)
),
radish@utils:prepare(_pipe@1).
-spec llen(binary()) -> bitstring().
llen(Key) ->
_pipe = [<<"LLEN"/utf8>>, Key],
radish@utils:prepare(_pipe).
-spec lrange(binary(), integer(), integer()) -> bitstring().
lrange(Key, Start, End) ->
_pipe = [<<"LRANGE"/utf8>>,
Key,
gleam@int:to_string(Start),
gleam@int:to_string(End)],
radish@utils:prepare(_pipe).
-spec lpop(binary(), gleam@option:option(integer())) -> bitstring().
lpop(Key, Count) ->
_pipe = case Count of
none ->
[<<"LPOP"/utf8>>, Key];
{some, Count@1} ->
[<<"LPOP"/utf8>>, Key, gleam@int:to_string(Count@1)]
end,
radish@utils:prepare(_pipe).
-spec rpop(binary(), gleam@option:option(integer())) -> bitstring().
rpop(Key, Count) ->
_pipe = case Count of
none ->
[<<"RPOP"/utf8>>, Key];
{some, Count@1} ->
[<<"RPOP"/utf8>>, Key, gleam@int:to_string(Count@1)]
end,
radish@utils:prepare(_pipe).