-module(radish@command@list). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function]). -export([lpush/2, rpush/2, lpushx/2, rpushx/2, len/1, range/3, lpop/2, blpop/2, rpop/2, brpop/2, index/2, 'rem'/3, set/3, insert_after/3, insert_before/3]). -spec lpush(binary(), list(binary())) -> bitstring(). lpush(Key, Values) -> _pipe = [<<"LPUSH"/utf8>>, Key], _pipe@1 = gleam@list:append(_pipe, Values), radish@utils:prepare(_pipe@1). -spec rpush(binary(), list(binary())) -> bitstring(). rpush(Key, Values) -> _pipe = [<<"RPUSH"/utf8>>, Key], _pipe@1 = gleam@list:append(_pipe, Values), radish@utils:prepare(_pipe@1). -spec lpushx(binary(), list(binary())) -> bitstring(). lpushx(Key, Values) -> _pipe = [<<"LPUSHX"/utf8>>, Key], _pipe@1 = gleam@list:append(_pipe, Values), radish@utils:prepare(_pipe@1). -spec rpushx(binary(), list(binary())) -> bitstring(). rpushx(Key, Values) -> _pipe = [<<"RPUSHX"/utf8>>, Key], _pipe@1 = gleam@list:append(_pipe, Values), radish@utils:prepare(_pipe@1). -spec len(binary()) -> bitstring(). len(Key) -> _pipe = [<<"LLEN"/utf8>>, Key], radish@utils:prepare(_pipe). -spec range(binary(), integer(), integer()) -> bitstring(). range(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 blpop(list(binary()), integer()) -> bitstring(). blpop(Keys, Timeout) -> _assert_subject = begin _pipe = Timeout, _pipe@1 = gleam@int:to_float(_pipe), gleam@float:divide(_pipe@1, 1000.0) end, {ok, Timeout@1} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"radish/command/list"/utf8>>, function => <<"blpop"/utf8>>, line => 50}) end, _pipe@2 = [<<"BLPOP"/utf8>>], _pipe@3 = gleam@list:append(_pipe@2, Keys), _pipe@6 = gleam@list:append( _pipe@3, [begin _pipe@4 = Timeout@1, _pipe@5 = gleam@float:round(_pipe@4), gleam@int:to_string(_pipe@5) end] ), radish@utils:prepare(_pipe@6). -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). -spec brpop(list(binary()), integer()) -> bitstring(). brpop(Keys, Timeout) -> _assert_subject = begin _pipe = Timeout, _pipe@1 = gleam@int:to_float(_pipe), gleam@float:divide(_pipe@1, 1000.0) end, {ok, Timeout@1} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"radish/command/list"/utf8>>, function => <<"brpop"/utf8>>, line => 74}) end, _pipe@2 = [<<"BRPOP"/utf8>>], _pipe@3 = gleam@list:append(_pipe@2, Keys), _pipe@6 = gleam@list:append( _pipe@3, [begin _pipe@4 = Timeout@1, _pipe@5 = gleam@float:round(_pipe@4), gleam@int:to_string(_pipe@5) end] ), radish@utils:prepare(_pipe@6). -spec index(binary(), integer()) -> bitstring(). index(Key, Index) -> _pipe = [<<"LINDEX"/utf8>>, Key, gleam@int:to_string(Index)], radish@utils:prepare(_pipe). -spec 'rem'(binary(), integer(), binary()) -> bitstring(). 'rem'(Key, Count, Value) -> _pipe = [<<"LREM"/utf8>>, Key, gleam@int:to_string(Count), Value], radish@utils:prepare(_pipe). -spec set(binary(), integer(), binary()) -> bitstring(). set(Key, Index, Value) -> _pipe = [<<"LSET"/utf8>>, Key, gleam@int:to_string(Index), Value], radish@utils:prepare(_pipe). -spec insert_after(binary(), binary(), binary()) -> bitstring(). insert_after(Key, Pivot, Value) -> _pipe = [<<"LINSERT"/utf8>>, Key, <<"AFTER"/utf8>>, Pivot, Value], radish@utils:prepare(_pipe). -spec insert_before(binary(), binary(), binary()) -> bitstring(). insert_before(Key, Pivot, Value) -> _pipe = [<<"LINSERT"/utf8>>, Key, <<"BEFORE"/utf8>>, Pivot, Value], radish@utils:prepare(_pipe).