···180180}
181181182182/// Cache layer for resolver operations
183183+///
184184+/// Fairly simple, in-memory only. If you want something more complex with persistence,
185185+/// implemement the appropriate resolver traits on your own struct, or wrap
186186+/// JacquardResolver in a custom cache layer. The intent here is to allow your
187187+/// backend service to not hammer people's DNS or PDS/entryway if you make requests
188188+/// that need to do resolution first (e.g. the get_record helper functions), not
189189+/// to provide a complete caching solution for all use cases of the resolver.
190190+///
191191+/// **Note from the author:** If there is desire or need, I can break out cache operation
192192+/// functions into a trait to make this more pluggable, but this solves the typical
193193+/// use case.
183194#[cfg(feature = "cache")]
184195#[derive(Clone)]
185185-struct ResolverCaches {
186186- handle_to_did: Cache<Handle<'static>, Did<'static>>,
187187- did_to_doc: Cache<Did<'static>, Arc<DidDocResponse>>,
188188- authority_to_did: Cache<SmolStr, Did<'static>>,
189189- nsid_to_schema: Cache<Nsid<'static>, Arc<ResolvedLexiconSchema<'static>>>,
196196+pub struct ResolverCaches {
197197+ pub handle_to_did: Cache<Handle<'static>, Did<'static>>,
198198+ pub did_to_doc: Cache<Did<'static>, Arc<DidDocResponse>>,
199199+ pub authority_to_did: Cache<SmolStr, Did<'static>>,
200200+ pub nsid_to_schema: Cache<Nsid<'static>, Arc<ResolvedLexiconSchema<'static>>>,
190201}
191202192203#[cfg(feature = "cache")]
193204impl ResolverCaches {
194194- fn new(config: &CacheConfig) -> Self {
205205+ pub fn new(config: &CacheConfig) -> Self {
195206 Self {
196207 handle_to_did: Cache::builder()
197208 .max_capacity(config.handle_to_did_capacity)
···910921 let resolver = JacquardResolver::new(http, opts);
911922 #[cfg(feature = "dns")]
912923 let resolver = resolver.with_system_dns();
924924+ #[cfg(feature = "cache")]
925925+ let resolver = resolver.with_cache();
913926 resolver
914927 }
915928}
···923936 let resolver = JacquardResolver::new(http, opts);
924937 #[cfg(feature = "dns")]
925938 let resolver = resolver.with_system_dns();
939939+ #[cfg(feature = "cache")]
940940+ let resolver = resolver.with_cache();
926941 resolver
927942}
928943