-module(radish@hash). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([set/4, set_new/5, len/3, keys/3, get/4, get_all/3, mget/4, strlen/4, vals/3, del/4, exists/4, incr_by/5, incr_by_float/5, scan/5, scan_pattern/6]). -file("/home/massivefermion/Desktop/radish/src/radish/hash.gleam", 13). -spec set( lifeguard:pool(radish@client:message()), binary(), gleam@dict:dict(binary(), binary()), integer() ) -> {ok, integer()} | {error, radish@error:error()}. set(Client, Key, Map, Timeout) -> _pipe = radish@command@hash:set(Key, maps:to_list(Map)), _pipe@1 = radish@utils:execute(Client, _pipe, Timeout), _pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of [{integer, N}] -> {ok, N}; _ -> {error, resp_error} end end), gleam@result:flatten(_pipe@2). -file("/home/massivefermion/Desktop/radish/src/radish/hash.gleam", 26). -spec set_new( lifeguard:pool(radish@client:message()), binary(), binary(), binary(), integer() ) -> {ok, integer()} | {error, radish@error:error()}. set_new(Client, Key, Field, Value, Timeout) -> _pipe = radish@command@hash:set_new(Key, Field, Value), _pipe@1 = radish@utils:execute(Client, _pipe, Timeout), _pipe@2 = gleam@result:map(_pipe@1, fun(Value@1) -> case Value@1 of [{integer, N}] -> {ok, N}; _ -> {error, resp_error} end end), gleam@result:flatten(_pipe@2). -file("/home/massivefermion/Desktop/radish/src/radish/hash.gleam", 39). -spec len(lifeguard:pool(radish@client:message()), binary(), integer()) -> {ok, integer()} | {error, radish@error:error()}. len(Client, Key, Timeout) -> _pipe = radish@command@hash:len(Key), _pipe@1 = radish@utils:execute(Client, _pipe, Timeout), _pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of [{integer, N}] -> {ok, N}; _ -> {error, resp_error} end end), gleam@result:flatten(_pipe@2). -file("/home/massivefermion/Desktop/radish/src/radish/hash.gleam", 52). -spec keys(lifeguard:pool(radish@client:message()), binary(), integer()) -> {ok, list(binary())} | {error, radish@error:error()}. keys(Client, Key, Timeout) -> _pipe = radish@command@hash:keys(Key), _pipe@1 = radish@utils:execute(Client, _pipe, Timeout), _pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of [{array, Array}] -> gleam@list:try_map(Array, fun(Item) -> case Item of {bulk_string, Str} -> {ok, Str}; _ -> {error, resp_error} end end); _ -> {error, resp_error} end end), gleam@result:flatten(_pipe@2). -file("/home/massivefermion/Desktop/radish/src/radish/hash.gleam", 71). -spec get( lifeguard:pool(radish@client:message()), binary(), binary(), integer() ) -> {ok, binary()} | {error, radish@error:error()}. get(Client, Key, Field, Timeout) -> _pipe = radish@command@hash:get(Key, Field), _pipe@1 = radish@utils:execute(Client, _pipe, Timeout), _pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of [{bulk_string, Str}] -> {ok, Str}; [null] -> {error, not_found}; _ -> {error, resp_error} end end), gleam@result:flatten(_pipe@2). -file("/home/massivefermion/Desktop/radish/src/radish/hash.gleam", 85). -spec get_all(lifeguard:pool(radish@client:message()), binary(), integer()) -> {ok, gleam@dict:dict(radish@resp:value(), radish@resp:value())} | {error, radish@error:error()}. get_all(Client, Key, Timeout) -> _pipe = radish@command@hash:get_all(Key), _pipe@1 = radish@utils:execute(Client, _pipe, Timeout), _pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of [{map, Map}] -> {ok, Map}; [{array, []}] -> {error, not_found}; _ -> {error, resp_error} end end), gleam@result:flatten(_pipe@2). -file("/home/massivefermion/Desktop/radish/src/radish/hash.gleam", 99). -spec mget( lifeguard:pool(radish@client:message()), binary(), list(binary()), integer() ) -> {ok, list(binary())} | {error, radish@error:error()}. mget(Client, Key, Fields, Timeout) -> _pipe = radish@command@hash:mget(Key, Fields), _pipe@1 = radish@utils:execute(Client, _pipe, Timeout), _pipe@4 = gleam@result:map(_pipe@1, fun(Value) -> case Value of [{array, Array}] -> _pipe@2 = Array, _pipe@3 = gleam@list:filter( _pipe@2, fun(Item) -> case Item of {bulk_string, _} -> true; _ -> false end end ), gleam@list:try_map(_pipe@3, fun(Item@1) -> case Item@1 of {bulk_string, Str} -> {ok, Str}; _ -> {error, resp_error} end end); _ -> {error, resp_error} end end), gleam@result:flatten(_pipe@4). -file("/home/massivefermion/Desktop/radish/src/radish/hash.gleam", 125). -spec strlen( lifeguard:pool(radish@client:message()), binary(), binary(), integer() ) -> {ok, integer()} | {error, radish@error:error()}. strlen(Client, Key, Field, Timeout) -> _pipe = radish@command@hash:strlen(Key, Field), _pipe@1 = radish@utils:execute(Client, _pipe, Timeout), _pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of [{integer, N}] -> {ok, N}; _ -> {error, resp_error} end end), gleam@result:flatten(_pipe@2). -file("/home/massivefermion/Desktop/radish/src/radish/hash.gleam", 138). -spec vals(lifeguard:pool(radish@client:message()), binary(), integer()) -> {ok, list(binary())} | {error, radish@error:error()}. vals(Client, Key, Timeout) -> _pipe = radish@command@hash:vals(Key), _pipe@1 = radish@utils:execute(Client, _pipe, Timeout), _pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of [{array, Array}] -> gleam@list:try_map(Array, fun(Item) -> case Item of {bulk_string, Str} -> {ok, Str}; _ -> {error, resp_error} end end); _ -> {error, resp_error} end end), gleam@result:flatten(_pipe@2). -file("/home/massivefermion/Desktop/radish/src/radish/hash.gleam", 157). -spec del( lifeguard:pool(radish@client:message()), binary(), list(binary()), integer() ) -> {ok, integer()} | {error, radish@error:error()}. del(Client, Key, Fields, Timeout) -> _pipe = radish@command@hash:del(Key, Fields), _pipe@1 = radish@utils:execute(Client, _pipe, Timeout), _pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of [{integer, N}] -> {ok, N}; _ -> {error, resp_error} end end), gleam@result:flatten(_pipe@2). -file("/home/massivefermion/Desktop/radish/src/radish/hash.gleam", 170). -spec exists( lifeguard:pool(radish@client:message()), binary(), binary(), integer() ) -> {ok, integer()} | {error, radish@error:error()}. exists(Client, Key, Field, Timeout) -> _pipe = radish@command@hash:exists(Key, Field), _pipe@1 = radish@utils:execute(Client, _pipe, Timeout), _pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of [{integer, N}] -> {ok, N}; _ -> {error, resp_error} end end), gleam@result:flatten(_pipe@2). -file("/home/massivefermion/Desktop/radish/src/radish/hash.gleam", 183). -spec incr_by( lifeguard:pool(radish@client:message()), binary(), binary(), integer(), integer() ) -> {ok, integer()} | {error, radish@error:error()}. incr_by(Client, Key, Field, Value, Timeout) -> _pipe = radish@command@hash:incr_by(Key, Field, Value), _pipe@1 = radish@utils:execute(Client, _pipe, Timeout), _pipe@2 = gleam@result:map(_pipe@1, fun(Value@1) -> case Value@1 of [{integer, N}] -> {ok, N}; _ -> {error, resp_error} end end), gleam@result:flatten(_pipe@2). -file("/home/massivefermion/Desktop/radish/src/radish/hash.gleam", 196). -spec incr_by_float( lifeguard:pool(radish@client:message()), binary(), binary(), float(), integer() ) -> {ok, float()} | {error, radish@error:error()}. incr_by_float(Client, Key, Field, Value, Timeout) -> _pipe = radish@command@hash:incr_by_float(Key, Field, Value), _pipe@1 = radish@utils:execute(Client, _pipe, Timeout), _pipe@2 = gleam@result:map(_pipe@1, fun(Value@1) -> case Value@1 of [{bulk_string, Str_value}] -> case gleam_stdlib:parse_int(Str_value) of {ok, N} -> {ok, erlang:float(N)}; {error, nil} -> case gleam_stdlib:parse_float(Str_value) of {ok, F} -> {ok, F}; {error, nil} -> {error, resp_error} end end; _ -> {error, resp_error} end end), gleam@result:flatten(_pipe@2). -file("/home/massivefermion/Desktop/radish/src/radish/hash.gleam", 223). -spec scan( lifeguard:pool(radish@client:message()), binary(), integer(), integer(), integer() ) -> {ok, {list(binary()), integer()}} | {error, radish@error:error()}. scan(Client, Key, Cursor, Count, Timeout) -> _pipe = radish@command@hash:scan(Key, Cursor, Count), _pipe@1 = radish@utils:execute(Client, _pipe, Timeout), _pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of [{array, [{bulk_string, New_cursor_str}, {array, Keys}]}] -> case gleam_stdlib:parse_int(New_cursor_str) of {ok, New_cursor} -> gleam@result:then( gleam@list:try_map( Keys, fun(Item) -> case Item of {bulk_string, Value@1} -> {ok, Value@1}; _ -> {error, resp_error} end end ), fun(Array) -> {ok, {Array, New_cursor}} end ); {error, nil} -> {error, resp_error} end; _ -> {error, resp_error} end end), gleam@result:flatten(_pipe@2). -file("/home/massivefermion/Desktop/radish/src/radish/hash.gleam", 250). -spec scan_pattern( lifeguard:pool(radish@client:message()), binary(), integer(), binary(), integer(), integer() ) -> {ok, {list(binary()), integer()}} | {error, radish@error:error()}. scan_pattern(Client, Key, Cursor, Pattern, Count, Timeout) -> _pipe = radish@command@hash:scan_pattern(Key, Cursor, Pattern, Count), _pipe@1 = radish@utils:execute(Client, _pipe, Timeout), _pipe@2 = gleam@result:map(_pipe@1, fun(Value) -> case Value of [{array, [{bulk_string, New_cursor_str}, {array, Keys}]}] -> case gleam_stdlib:parse_int(New_cursor_str) of {ok, New_cursor} -> gleam@result:then( gleam@list:try_map( Keys, fun(Item) -> case Item of {bulk_string, Value@1} -> {ok, Value@1}; _ -> {error, resp_error} end end ), fun(Array) -> {ok, {Array, New_cursor}} end ); {error, nil} -> {error, resp_error} end; _ -> {error, resp_error} end end), gleam@result:flatten(_pipe@2).