Current section

Files

Jump to
radish src radish@command.erl
Raw

src/radish@command.erl

-module(radish@command).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([hello/2, custom/1, keys/1, scan/2, scan_pattern/3, scan_with_type/3, scan_pattern_with_type/4, exists/1, get/1, mget/1, append/2, set/3, mset/1, del/1, incr/1, incr_by/2, incr_by_float/2, decr/1, decr_by/2, random_key/0, key_type/1, rename/2, renamenx/2, persist/1, ping/0, ping_message/1, expire/3, publish/2, subscribe/1, subscribe_to_patterns/1, unsubscribe/1, unsubscribe_from_all/0, unsubscribe_from_patterns/1, unsubscribe_from_all_patterns/0]).
-export_type([hello_option/0, set_option/0]).
-type hello_option() :: {auth, binary()} |
{auth_with_username, binary(), binary()}.
-type set_option() :: nx |
xx |
get |
keepttl |
{ex, integer()} |
{px, integer()} |
{exat, integer()} |
{pxat, integer()}.
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 24).
-spec hello(integer(), list(hello_option())) -> bitstring().
hello(Protocol, Options) ->
_pipe = [<<"HELLO"/utf8>>, erlang:integer_to_binary(Protocol)],
_pipe@1 = lists:append(
_pipe,
gleam@list:flat_map(Options, fun(Item) -> case Item of
{auth, Password} ->
[<<"AUTH"/utf8>>, <<"default"/utf8>>, Password];
{auth_with_username, Username, Password@1} ->
[<<"AUTH"/utf8>>, Username, Password@1]
end end)
),
radish@utils:prepare(_pipe@1).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 37).
-spec custom(list(binary())) -> bitstring().
custom(Command) ->
radish@utils:prepare(Command).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 41).
-spec keys(binary()) -> bitstring().
keys(Pattern) ->
_pipe = [<<"KEYS"/utf8>>, Pattern],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 46).
-spec scan(integer(), integer()) -> bitstring().
scan(Cursor, Count) ->
_pipe = [<<"SCAN"/utf8>>,
erlang:integer_to_binary(Cursor),
<<"COUNT"/utf8>>,
erlang:integer_to_binary(Count)],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 51).
-spec scan_pattern(integer(), binary(), integer()) -> bitstring().
scan_pattern(Cursor, Pattern, Count) ->
_pipe = [<<"SCAN"/utf8>>,
erlang:integer_to_binary(Cursor),
<<"MATCH"/utf8>>,
Pattern,
<<"COUNT"/utf8>>,
erlang:integer_to_binary(Count)],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 63).
-spec scan_with_type(integer(), binary(), integer()) -> bitstring().
scan_with_type(Cursor, Key_type, Count) ->
_pipe = [<<"SCAN"/utf8>>,
erlang:integer_to_binary(Cursor),
<<"COUNT"/utf8>>,
erlang:integer_to_binary(Count),
<<"TYPE"/utf8>>,
Key_type],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 75).
-spec scan_pattern_with_type(integer(), binary(), binary(), integer()) -> bitstring().
scan_pattern_with_type(Cursor, Key_type, Pattern, Count) ->
_pipe = [<<"SCAN"/utf8>>,
erlang:integer_to_binary(Cursor),
<<"MATCH"/utf8>>,
Pattern,
<<"COUNT"/utf8>>,
erlang:integer_to_binary(Count),
<<"TYPE"/utf8>>,
Key_type],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 94).
-spec exists(list(binary())) -> bitstring().
exists(Keys) ->
_pipe = [<<"EXISTS"/utf8>>],
_pipe@1 = lists:append(_pipe, Keys),
radish@utils:prepare(_pipe@1).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 100).
-spec get(binary()) -> bitstring().
get(Key) ->
_pipe = [<<"GET"/utf8>>, Key],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 105).
-spec mget(list(binary())) -> bitstring().
mget(Keys) ->
_pipe = [<<"MGET"/utf8>>],
_pipe@1 = lists:append(_pipe, Keys),
radish@utils:prepare(_pipe@1).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 111).
-spec append(binary(), binary()) -> bitstring().
append(Key, Value) ->
_pipe = [<<"APPEND"/utf8>>, Key, Value],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 116).
-spec set(binary(), binary(), list(set_option())) -> bitstring().
set(Key, Value, Options) ->
_pipe = gleam@list:fold(
Options,
[<<"SET"/utf8>>, Key, Value],
fun(Cmd, Option) -> case Option of
nx ->
lists:append(Cmd, [<<"NX"/utf8>>]);
xx ->
lists:append(Cmd, [<<"XX"/utf8>>]);
get ->
lists:append(Cmd, [<<"GET"/utf8>>]);
keepttl ->
lists:append(Cmd, [<<"KEEPTTL"/utf8>>]);
{ex, Value@1} ->
lists:append(
Cmd,
[<<"EX"/utf8>>, erlang:integer_to_binary(Value@1)]
);
{px, Value@2} ->
lists:append(
Cmd,
[<<"PX"/utf8>>, erlang:integer_to_binary(Value@2)]
);
{exat, Value@3} ->
lists:append(
Cmd,
[<<"EXAT"/utf8>>, erlang:integer_to_binary(Value@3)]
);
{pxat, Value@4} ->
lists:append(
Cmd,
[<<"PXAT"/utf8>>, erlang:integer_to_binary(Value@4)]
)
end end
),
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 132).
-spec mset(list({binary(), binary()})) -> bitstring().
mset(Kv_list) ->
_pipe = Kv_list,
_pipe@1 = gleam@list:map(
_pipe,
fun(Kv) -> [erlang:element(1, Kv), erlang:element(2, Kv)] end
),
_pipe@2 = gleam@list:flatten(_pipe@1),
_pipe@3 = lists:append([<<"MSET"/utf8>>], _pipe@2),
radish@utils:prepare(_pipe@3).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 140).
-spec del(list(binary())) -> bitstring().
del(Keys) ->
_pipe = [<<"DEL"/utf8>>],
_pipe@1 = lists:append(_pipe, Keys),
radish@utils:prepare(_pipe@1).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 146).
-spec incr(binary()) -> bitstring().
incr(Key) ->
_pipe = [<<"INCR"/utf8>>, Key],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 151).
-spec incr_by(binary(), integer()) -> bitstring().
incr_by(Key, Value) ->
_pipe = [<<"INCRBY"/utf8>>, Key, erlang:integer_to_binary(Value)],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 156).
-spec incr_by_float(binary(), float()) -> bitstring().
incr_by_float(Key, Value) ->
_pipe = [<<"INCRBYFLOAT"/utf8>>, Key, gleam_stdlib:float_to_string(Value)],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 161).
-spec decr(binary()) -> bitstring().
decr(Key) ->
_pipe = [<<"DECR"/utf8>>, Key],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 166).
-spec decr_by(binary(), integer()) -> bitstring().
decr_by(Key, Value) ->
_pipe = [<<"DECRBY"/utf8>>, Key, erlang:integer_to_binary(Value)],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 171).
-spec random_key() -> bitstring().
random_key() ->
_pipe = [<<"RANDOMKEY"/utf8>>],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 176).
-spec key_type(binary()) -> bitstring().
key_type(Key) ->
_pipe = [<<"TYPE"/utf8>>, Key],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 181).
-spec rename(binary(), binary()) -> bitstring().
rename(Key, New_key) ->
_pipe = [<<"RENAME"/utf8>>, Key, New_key],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 186).
-spec renamenx(binary(), binary()) -> bitstring().
renamenx(Key, New_key) ->
_pipe = [<<"RENAMENX"/utf8>>, Key, New_key],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 191).
-spec persist(binary()) -> bitstring().
persist(Key) ->
_pipe = [<<"PERSIST"/utf8>>, Key],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 196).
-spec ping() -> bitstring().
ping() ->
_pipe = [<<"PING"/utf8>>],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 201).
-spec ping_message(binary()) -> bitstring().
ping_message(Message) ->
_pipe = [<<"PING"/utf8>>, Message],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 206).
-spec expire(binary(), integer(), gleam@option:option(binary())) -> bitstring().
expire(Key, Ttl, Expire_if) ->
_pipe = case Expire_if of
none ->
[<<"EXPIRE"/utf8>>, Key, erlang:integer_to_binary(Ttl)];
{some, Condition} ->
[<<"EXPIRE"/utf8>>, Key, erlang:integer_to_binary(Ttl), Condition]
end,
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 214).
-spec publish(binary(), binary()) -> bitstring().
publish(Channel, Message) ->
_pipe = [<<"PUBLISH"/utf8>>, Channel, Message],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 219).
-spec subscribe(list(binary())) -> bitstring().
subscribe(Channels) ->
_pipe = [<<"SUBSCRIBE"/utf8>>],
_pipe@1 = lists:append(_pipe, Channels),
radish@utils:prepare(_pipe@1).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 225).
-spec subscribe_to_patterns(list(binary())) -> bitstring().
subscribe_to_patterns(Patterns) ->
_pipe = [<<"PSUBSCRIBE"/utf8>>],
_pipe@1 = lists:append(_pipe, Patterns),
radish@utils:prepare(_pipe@1).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 231).
-spec unsubscribe(list(binary())) -> bitstring().
unsubscribe(Channels) ->
_pipe = [<<"UNSUBSCRIBE"/utf8>>],
_pipe@1 = lists:append(_pipe, Channels),
radish@utils:prepare(_pipe@1).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 237).
-spec unsubscribe_from_all() -> bitstring().
unsubscribe_from_all() ->
_pipe = [<<"UNSUBSCRIBE"/utf8>>],
radish@utils:prepare(_pipe).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 242).
-spec unsubscribe_from_patterns(list(binary())) -> bitstring().
unsubscribe_from_patterns(Patterns) ->
_pipe = [<<"PUNSUBSCRIBE"/utf8>>],
_pipe@1 = lists:append(_pipe, Patterns),
radish@utils:prepare(_pipe@1).
-file("/home/massivefermion/Desktop/radish/src/radish/command.gleam", 248).
-spec unsubscribe_from_all_patterns() -> bitstring().
unsubscribe_from_all_patterns() ->
_pipe = [<<"PUNSUBSCRIBE"/utf8>>],
radish@utils:prepare(_pipe).