From f3a107111f6f82d342d885d74c4d7a8f927201ab Mon Sep 17 00:00:00 2001 From: Peter Harpending Date: Wed, 22 Oct 2025 13:33:08 -0700 Subject: [PATCH] add query function --- src/fd_sfc_cache.erl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/fd_sfc_cache.erl b/src/fd_sfc_cache.erl index dd629d3..462cb96 100644 --- a/src/fd_sfc_cache.erl +++ b/src/fd_sfc_cache.erl @@ -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() -> #{}.