add query function

This commit is contained in:
Peter Harpending 2025-10-22 13:33:08 -07:00
parent 8b938fdd42
commit f3a107111f

View File

@ -7,6 +7,7 @@
]).
-export([
query/2,
new/0, new/1
]).
@ -15,6 +16,20 @@
-type cache() :: #{HttpPath :: binary() := Entry :: fd_sfc_entry:entry()}.
-spec query(HttpPath, Cache) -> Result
when HttpPath :: binary(),
Cache :: cache(),
Result :: {found, Entry}
| not_found,
Entry :: fd_sfc_entry:entry().
query(HttpPath, Cache) ->
case maps:find(HttpPath, Cache) of
{ok, Entry} -> {found, Entry};
error -> not_found
end.
-spec new() -> cache().
new() -> #{}.