Packages

A Gleam client for Valkey, KeyDB, Redis, Dragonfly and other Redis-compatible databases.

Current section

Files

Jump to
valkyrie src valkyrie@internal@commands.erl
Raw

src/valkyrie@internal@commands.erl

-module(valkyrie@internal@commands).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/valkyrie/internal/commands.gleam").
-export([keys/1, scan/4, exists/1, get/1, mget/1, append/2, set/3, mset/1, del/1, incr/1, incrby/2, incrbyfloat/2, decr/1, decrby/2, randomkey/0, key_type/1, rename/2, renamenx/2, persist/1, ping/1, expire/3, pexpire/3, expireat/3, expiretime/1, pexpiretime/1, lpush/2, rpush/2, lpushx/2, rpushx/2, llen/1, lrange/3, lpop/2, rpop/2, lindex/2, lrem/3, lset/3, linsert/4, sadd/2, scard/1, sismember/2, smembers/1, sscan/4, zadd/2, zincrby/3, zcard/1, zcount/3, zscore/2, zscan/4, zrem/2, zrandmember/2, zpopmin/2, zpopmax/2, zrange/4, zrank/2, zrank_withscore/2, zrevrank/2, zrevrank_withscore/2, hset/2, hsetnx/3, hlen/1, hkeys/1, hget/2, hgetall/1, hmget/2, hstrlen/2, hvals/1, hdel/2, hexists/2, hincrby/3, hincrbyfloat/3, hscan/4]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(false).
-file("src/valkyrie/internal/commands.gleam", 11).
?DOC(false).
-spec keys(binary()) -> list(binary()).
keys(Pattern) ->
[<<"KEYS"/utf8>>, Pattern].
-file("src/valkyrie/internal/commands.gleam", 15).
?DOC(false).
-spec scan(
integer(),
gleam@option:option(binary()),
integer(),
gleam@option:option(binary())
) -> list(binary()).
scan(Cursor, Pattern_filter, Count, Key_type_filter) ->
Modifiers = case Key_type_filter of
{some, Key_type} ->
[<<"TYPE"/utf8>>, Key_type];
none ->
[]
end,
Modifiers@1 = [<<"COUNT"/utf8>>,
erlang:integer_to_binary(Count) |
Modifiers],
Modifiers@2 = case Pattern_filter of
{some, Pattern} ->
[<<"MATCH"/utf8>>, Pattern | Modifiers@1];
none ->
Modifiers@1
end,
[<<"SCAN"/utf8>>, erlang:integer_to_binary(Cursor) | Modifiers@2].
-file("src/valkyrie/internal/commands.gleam", 33).
?DOC(false).
-spec exists(list(binary())) -> list(binary()).
exists(Keys) ->
[<<"EXISTS"/utf8>> | Keys].
-file("src/valkyrie/internal/commands.gleam", 37).
?DOC(false).
-spec get(binary()) -> list(binary()).
get(Key) ->
[<<"GET"/utf8>>, Key].
-file("src/valkyrie/internal/commands.gleam", 41).
?DOC(false).
-spec mget(list(binary())) -> list(binary()).
mget(Keys) ->
[<<"MGET"/utf8>> | Keys].
-file("src/valkyrie/internal/commands.gleam", 45).
?DOC(false).
-spec append(binary(), binary()) -> list(binary()).
append(Key, Value) ->
[<<"APPEND"/utf8>>, Key, Value].
-file("src/valkyrie/internal/commands.gleam", 49).
?DOC(false).
-spec set(binary(), binary(), list(binary())) -> list(binary()).
set(Key, Value, Modifiers) ->
[<<"SET"/utf8>>, Key, Value | Modifiers].
-file("src/valkyrie/internal/commands.gleam", 53).
?DOC(false).
-spec mset(list({binary(), binary()})) -> list(binary()).
mset(Kv_list) ->
Kv_list@1 = begin
_pipe = Kv_list,
_pipe@1 = gleam@list:map(
_pipe,
fun(Kv) -> [erlang:element(1, Kv), erlang:element(2, Kv)] end
),
lists:append(_pipe@1)
end,
[<<"MSET"/utf8>> | Kv_list@1].
-file("src/valkyrie/internal/commands.gleam", 61).
?DOC(false).
-spec del(list(binary())) -> list(binary()).
del(Keys) ->
[<<"DEL"/utf8>> | Keys].
-file("src/valkyrie/internal/commands.gleam", 65).
?DOC(false).
-spec incr(binary()) -> list(binary()).
incr(Key) ->
[<<"INCR"/utf8>>, Key].
-file("src/valkyrie/internal/commands.gleam", 69).
?DOC(false).
-spec incrby(binary(), integer()) -> list(binary()).
incrby(Key, Value) ->
[<<"INCRBY"/utf8>>, Key, erlang:integer_to_binary(Value)].
-file("src/valkyrie/internal/commands.gleam", 73).
?DOC(false).
-spec incrbyfloat(binary(), float()) -> list(binary()).
incrbyfloat(Key, Value) ->
[<<"INCRBYFLOAT"/utf8>>, Key, gleam_stdlib:float_to_string(Value)].
-file("src/valkyrie/internal/commands.gleam", 77).
?DOC(false).
-spec decr(binary()) -> list(binary()).
decr(Key) ->
[<<"DECR"/utf8>>, Key].
-file("src/valkyrie/internal/commands.gleam", 81).
?DOC(false).
-spec decrby(binary(), integer()) -> list(binary()).
decrby(Key, Value) ->
[<<"DECRBY"/utf8>>, Key, erlang:integer_to_binary(Value)].
-file("src/valkyrie/internal/commands.gleam", 85).
?DOC(false).
-spec randomkey() -> list(binary()).
randomkey() ->
[<<"RANDOMKEY"/utf8>>].
-file("src/valkyrie/internal/commands.gleam", 89).
?DOC(false).
-spec key_type(binary()) -> list(binary()).
key_type(Key) ->
[<<"TYPE"/utf8>>, Key].
-file("src/valkyrie/internal/commands.gleam", 93).
?DOC(false).
-spec rename(binary(), binary()) -> list(binary()).
rename(Key, New_key) ->
[<<"RENAME"/utf8>>, Key, New_key].
-file("src/valkyrie/internal/commands.gleam", 97).
?DOC(false).
-spec renamenx(binary(), binary()) -> list(binary()).
renamenx(Key, New_key) ->
[<<"RENAMENX"/utf8>>, Key, New_key].
-file("src/valkyrie/internal/commands.gleam", 101).
?DOC(false).
-spec persist(binary()) -> list(binary()).
persist(Key) ->
[<<"PERSIST"/utf8>>, Key].
-file("src/valkyrie/internal/commands.gleam", 105).
?DOC(false).
-spec ping(gleam@option:option(binary())) -> list(binary()).
ping(Message) ->
case Message of
none ->
[<<"PING"/utf8>>];
{some, Msg} ->
[<<"PING"/utf8>>, Msg]
end.
-file("src/valkyrie/internal/commands.gleam", 112).
?DOC(false).
-spec expire(binary(), integer(), list(binary())) -> list(binary()).
expire(Key, Ttl, Expiry_condition) ->
[<<"EXPIRE"/utf8>>, Key, erlang:integer_to_binary(Ttl) | Expiry_condition].
-file("src/valkyrie/internal/commands.gleam", 120).
?DOC(false).
-spec pexpire(binary(), integer(), list(binary())) -> list(binary()).
pexpire(Key, Ttl, Expiry_condition) ->
[<<"PEXPIRE"/utf8>>, Key, erlang:integer_to_binary(Ttl) | Expiry_condition].
-file("src/valkyrie/internal/commands.gleam", 128).
?DOC(false).
-spec expireat(binary(), integer(), list(binary())) -> list(binary()).
expireat(Key, Unix_seconds, Expiry_condition) ->
[<<"EXPIREAT"/utf8>>,
Key,
erlang:integer_to_binary(Unix_seconds) |
Expiry_condition].
-file("src/valkyrie/internal/commands.gleam", 136).
?DOC(false).
-spec expiretime(binary()) -> list(binary()).
expiretime(Key) ->
[<<"EXPIRETIME"/utf8>>, Key].
-file("src/valkyrie/internal/commands.gleam", 140).
?DOC(false).
-spec pexpiretime(binary()) -> list(binary()).
pexpiretime(Key) ->
[<<"PEXPIRETIME"/utf8>>, Key].
-file("src/valkyrie/internal/commands.gleam", 148).
?DOC(false).
-spec lpush(binary(), list(binary())) -> list(binary()).
lpush(Key, Values) ->
[<<"LPUSH"/utf8>>, Key | Values].
-file("src/valkyrie/internal/commands.gleam", 152).
?DOC(false).
-spec rpush(binary(), list(binary())) -> list(binary()).
rpush(Key, Values) ->
[<<"RPUSH"/utf8>>, Key | Values].
-file("src/valkyrie/internal/commands.gleam", 156).
?DOC(false).
-spec lpushx(binary(), list(binary())) -> list(binary()).
lpushx(Key, Values) ->
[<<"LPUSHX"/utf8>>, Key | Values].
-file("src/valkyrie/internal/commands.gleam", 160).
?DOC(false).
-spec rpushx(binary(), list(binary())) -> list(binary()).
rpushx(Key, Values) ->
[<<"RPUSHX"/utf8>>, Key | Values].
-file("src/valkyrie/internal/commands.gleam", 164).
?DOC(false).
-spec llen(binary()) -> list(binary()).
llen(Key) ->
[<<"LLEN"/utf8>>, Key].
-file("src/valkyrie/internal/commands.gleam", 168).
?DOC(false).
-spec lrange(binary(), integer(), integer()) -> list(binary()).
lrange(Key, Start, End) ->
[<<"LRANGE"/utf8>>,
Key,
erlang:integer_to_binary(Start),
erlang:integer_to_binary(End)].
-file("src/valkyrie/internal/commands.gleam", 172).
?DOC(false).
-spec lpop(binary(), integer()) -> list(binary()).
lpop(Key, Count) ->
[<<"LPOP"/utf8>>, Key, erlang:integer_to_binary(Count)].
-file("src/valkyrie/internal/commands.gleam", 176).
?DOC(false).
-spec rpop(binary(), integer()) -> list(binary()).
rpop(Key, Count) ->
[<<"RPOP"/utf8>>, Key, erlang:integer_to_binary(Count)].
-file("src/valkyrie/internal/commands.gleam", 180).
?DOC(false).
-spec lindex(binary(), integer()) -> list(binary()).
lindex(Key, Index) ->
[<<"LINDEX"/utf8>>, Key, erlang:integer_to_binary(Index)].
-file("src/valkyrie/internal/commands.gleam", 184).
?DOC(false).
-spec lrem(binary(), integer(), binary()) -> list(binary()).
lrem(Key, Count, Value) ->
[<<"LREM"/utf8>>, Key, erlang:integer_to_binary(Count), Value].
-file("src/valkyrie/internal/commands.gleam", 188).
?DOC(false).
-spec lset(binary(), integer(), binary()) -> list(binary()).
lset(Key, Index, Value) ->
[<<"LSET"/utf8>>, Key, erlang:integer_to_binary(Index), Value].
-file("src/valkyrie/internal/commands.gleam", 192).
?DOC(false).
-spec linsert(binary(), binary(), binary(), binary()) -> list(binary()).
linsert(Key, Position, Pivot, Value) ->
[<<"LINSERT"/utf8>>, Key, Position, Pivot, Value].
-file("src/valkyrie/internal/commands.gleam", 205).
?DOC(false).
-spec sadd(binary(), list(binary())) -> list(binary()).
sadd(Key, Values) ->
[<<"SADD"/utf8>>, Key | Values].
-file("src/valkyrie/internal/commands.gleam", 209).
?DOC(false).
-spec scard(binary()) -> list(binary()).
scard(Key) ->
[<<"SCARD"/utf8>>, Key].
-file("src/valkyrie/internal/commands.gleam", 213).
?DOC(false).
-spec sismember(binary(), binary()) -> list(binary()).
sismember(Key, Value) ->
[<<"SISMEMBER"/utf8>>, Key, Value].
-file("src/valkyrie/internal/commands.gleam", 217).
?DOC(false).
-spec smembers(binary()) -> list(binary()).
smembers(Key) ->
[<<"SMEMBERS"/utf8>>, Key].
-file("src/valkyrie/internal/commands.gleam", 221).
?DOC(false).
-spec sscan(binary(), integer(), gleam@option:option(binary()), integer()) -> list(binary()).
sscan(Key, Cursor, Pattern_filter, Count) ->
Modifiers = case Pattern_filter of
{some, Pattern} ->
[<<"MATCH"/utf8>>,
Pattern,
<<"COUNT"/utf8>>,
erlang:integer_to_binary(Count)];
none ->
[<<"COUNT"/utf8>>, erlang:integer_to_binary(Count)]
end,
[<<"SSCAN"/utf8>>, Key, erlang:integer_to_binary(Cursor) | Modifiers].
-file("src/valkyrie/internal/commands.gleam", 238).
?DOC(false).
-spec zadd(binary(), list(binary())) -> list(binary()).
zadd(Key, Modifiers_and_members) ->
[<<"ZADD"/utf8>>, Key | Modifiers_and_members].
-file("src/valkyrie/internal/commands.gleam", 242).
?DOC(false).
-spec zincrby(binary(), binary(), binary()) -> list(binary()).
zincrby(Key, Delta, Member) ->
[<<"ZINCRBY"/utf8>>, Key, Delta, Member].
-file("src/valkyrie/internal/commands.gleam", 246).
?DOC(false).
-spec zcard(binary()) -> list(binary()).
zcard(Key) ->
[<<"ZCARD"/utf8>>, Key].
-file("src/valkyrie/internal/commands.gleam", 250).
?DOC(false).
-spec zcount(binary(), binary(), binary()) -> list(binary()).
zcount(Key, Min, Max) ->
[<<"ZCOUNT"/utf8>>, Key, Min, Max].
-file("src/valkyrie/internal/commands.gleam", 254).
?DOC(false).
-spec zscore(binary(), binary()) -> list(binary()).
zscore(Key, Member) ->
[<<"ZSCORE"/utf8>>, Key, Member].
-file("src/valkyrie/internal/commands.gleam", 258).
?DOC(false).
-spec zscan(binary(), integer(), gleam@option:option(binary()), integer()) -> list(binary()).
zscan(Key, Cursor, Pattern_filter, Count) ->
Modifiers = case Pattern_filter of
{some, Pattern} ->
[<<"MATCH"/utf8>>,
Pattern,
<<"COUNT"/utf8>>,
erlang:integer_to_binary(Count)];
none ->
[<<"COUNT"/utf8>>, erlang:integer_to_binary(Count)]
end,
[<<"ZSCAN"/utf8>>, Key, erlang:integer_to_binary(Cursor) | Modifiers].
-file("src/valkyrie/internal/commands.gleam", 271).
?DOC(false).
-spec zrem(binary(), list(binary())) -> list(binary()).
zrem(Key, Members) ->
[<<"ZREM"/utf8>>, Key | Members].
-file("src/valkyrie/internal/commands.gleam", 275).
?DOC(false).
-spec zrandmember(binary(), integer()) -> list(binary()).
zrandmember(Key, Count) ->
[<<"ZRANDMEMBER"/utf8>>,
Key,
erlang:integer_to_binary(Count),
<<"WITHSCORES"/utf8>>].
-file("src/valkyrie/internal/commands.gleam", 279).
?DOC(false).
-spec zpopmin(binary(), integer()) -> list(binary()).
zpopmin(Key, Count) ->
[<<"ZPOPMIN"/utf8>>, Key, erlang:integer_to_binary(Count)].
-file("src/valkyrie/internal/commands.gleam", 283).
?DOC(false).
-spec zpopmax(binary(), integer()) -> list(binary()).
zpopmax(Key, Count) ->
[<<"ZPOPMAX"/utf8>>, Key, erlang:integer_to_binary(Count)].
-file("src/valkyrie/internal/commands.gleam", 287).
?DOC(false).
-spec zrange(binary(), binary(), binary(), list(binary())) -> list(binary()).
zrange(Key, Start, Stop, Modifiers) ->
[<<"ZRANGE"/utf8>>, Key, Start, Stop | Modifiers].
-file("src/valkyrie/internal/commands.gleam", 296).
?DOC(false).
-spec zrank(binary(), binary()) -> list(binary()).
zrank(Key, Member) ->
[<<"ZRANK"/utf8>>, Key, Member].
-file("src/valkyrie/internal/commands.gleam", 300).
?DOC(false).
-spec zrank_withscore(binary(), binary()) -> list(binary()).
zrank_withscore(Key, Member) ->
[<<"ZRANK"/utf8>>, Key, Member, <<"WITHSCORE"/utf8>>].
-file("src/valkyrie/internal/commands.gleam", 304).
?DOC(false).
-spec zrevrank(binary(), binary()) -> list(binary()).
zrevrank(Key, Member) ->
[<<"ZREVRANK"/utf8>>, Key, Member].
-file("src/valkyrie/internal/commands.gleam", 308).
?DOC(false).
-spec zrevrank_withscore(binary(), binary()) -> list(binary()).
zrevrank_withscore(Key, Member) ->
[<<"ZREVRANK"/utf8>>, Key, Member, <<"WITHSCORE"/utf8>>].
-file("src/valkyrie/internal/commands.gleam", 316).
?DOC(false).
-spec hset(binary(), gleam@dict:dict(binary(), binary())) -> list(binary()).
hset(Key, Values) ->
Values@1 = begin
_pipe = Values,
_pipe@1 = maps:to_list(_pipe),
gleam@list:flat_map(
_pipe@1,
fun(Item) -> [erlang:element(1, Item), erlang:element(2, Item)] end
)
end,
[<<"HSET"/utf8>>, Key | Values@1].
-file("src/valkyrie/internal/commands.gleam", 324).
?DOC(false).
-spec hsetnx(binary(), binary(), binary()) -> list(binary()).
hsetnx(Key, Field, Value) ->
[<<"HSETNX"/utf8>>, Key, Field, Value].
-file("src/valkyrie/internal/commands.gleam", 328).
?DOC(false).
-spec hlen(binary()) -> list(binary()).
hlen(Key) ->
[<<"HLEN"/utf8>>, Key].
-file("src/valkyrie/internal/commands.gleam", 332).
?DOC(false).
-spec hkeys(binary()) -> list(binary()).
hkeys(Key) ->
[<<"HKEYS"/utf8>>, Key].
-file("src/valkyrie/internal/commands.gleam", 336).
?DOC(false).
-spec hget(binary(), binary()) -> list(binary()).
hget(Key, Field) ->
[<<"HGET"/utf8>>, Key, Field].
-file("src/valkyrie/internal/commands.gleam", 340).
?DOC(false).
-spec hgetall(binary()) -> list(binary()).
hgetall(Key) ->
[<<"HGETALL"/utf8>>, Key].
-file("src/valkyrie/internal/commands.gleam", 344).
?DOC(false).
-spec hmget(binary(), list(binary())) -> list(binary()).
hmget(Key, Fields) ->
[<<"HMGET"/utf8>>, Key | Fields].
-file("src/valkyrie/internal/commands.gleam", 348).
?DOC(false).
-spec hstrlen(binary(), binary()) -> list(binary()).
hstrlen(Key, Field) ->
[<<"HSTRLEN"/utf8>>, Key, Field].
-file("src/valkyrie/internal/commands.gleam", 352).
?DOC(false).
-spec hvals(binary()) -> list(binary()).
hvals(Key) ->
[<<"HVALS"/utf8>>, Key].
-file("src/valkyrie/internal/commands.gleam", 356).
?DOC(false).
-spec hdel(binary(), list(binary())) -> list(binary()).
hdel(Key, Fields) ->
[<<"HDEL"/utf8>>, Key | Fields].
-file("src/valkyrie/internal/commands.gleam", 360).
?DOC(false).
-spec hexists(binary(), binary()) -> list(binary()).
hexists(Key, Field) ->
[<<"HEXISTS"/utf8>>, Key, Field].
-file("src/valkyrie/internal/commands.gleam", 364).
?DOC(false).
-spec hincrby(binary(), binary(), integer()) -> list(binary()).
hincrby(Key, Field, Value) ->
[<<"HINCRBY"/utf8>>, Key, Field, erlang:integer_to_binary(Value)].
-file("src/valkyrie/internal/commands.gleam", 368).
?DOC(false).
-spec hincrbyfloat(binary(), binary(), float()) -> list(binary()).
hincrbyfloat(Key, Field, Value) ->
[<<"HINCRBYFLOAT"/utf8>>, Key, Field, gleam_stdlib:float_to_string(Value)].
-file("src/valkyrie/internal/commands.gleam", 372).
?DOC(false).
-spec hscan(binary(), integer(), gleam@option:option(binary()), integer()) -> list(binary()).
hscan(Key, Cursor, Pattern_filter, Count) ->
Modifiers = case Pattern_filter of
{some, Pattern} ->
[<<"MATCH"/utf8>>,
Pattern,
<<"COUNT"/utf8>>,
erlang:integer_to_binary(Count)];
none ->
[<<"COUNT"/utf8>>, erlang:integer_to_binary(Count)]
end,
[<<"HSCAN"/utf8>>, Key, erlang:integer_to_binary(Cursor) | Modifiers].