this repo has no description

note on the caches, also enabled by default if feature is enabled

Orual 1c2f11b9 e3b48af3

Changed files
+21 -6
crates
jacquard-identity
src
+21 -6
crates/jacquard-identity/src/lib.rs
··· 180 180 } 181 181 182 182 /// Cache layer for resolver operations 183 + /// 184 + /// Fairly simple, in-memory only. If you want something more complex with persistence, 185 + /// implemement the appropriate resolver traits on your own struct, or wrap 186 + /// JacquardResolver in a custom cache layer. The intent here is to allow your 187 + /// backend service to not hammer people's DNS or PDS/entryway if you make requests 188 + /// that need to do resolution first (e.g. the get_record helper functions), not 189 + /// to provide a complete caching solution for all use cases of the resolver. 190 + /// 191 + /// **Note from the author:** If there is desire or need, I can break out cache operation 192 + /// functions into a trait to make this more pluggable, but this solves the typical 193 + /// use case. 183 194 #[cfg(feature = "cache")] 184 195 #[derive(Clone)] 185 - struct ResolverCaches { 186 - handle_to_did: Cache<Handle<'static>, Did<'static>>, 187 - did_to_doc: Cache<Did<'static>, Arc<DidDocResponse>>, 188 - authority_to_did: Cache<SmolStr, Did<'static>>, 189 - nsid_to_schema: Cache<Nsid<'static>, Arc<ResolvedLexiconSchema<'static>>>, 196 + pub struct ResolverCaches { 197 + pub handle_to_did: Cache<Handle<'static>, Did<'static>>, 198 + pub did_to_doc: Cache<Did<'static>, Arc<DidDocResponse>>, 199 + pub authority_to_did: Cache<SmolStr, Did<'static>>, 200 + pub nsid_to_schema: Cache<Nsid<'static>, Arc<ResolvedLexiconSchema<'static>>>, 190 201 } 191 202 192 203 #[cfg(feature = "cache")] 193 204 impl ResolverCaches { 194 - fn new(config: &CacheConfig) -> Self { 205 + pub fn new(config: &CacheConfig) -> Self { 195 206 Self { 196 207 handle_to_did: Cache::builder() 197 208 .max_capacity(config.handle_to_did_capacity) ··· 910 921 let resolver = JacquardResolver::new(http, opts); 911 922 #[cfg(feature = "dns")] 912 923 let resolver = resolver.with_system_dns(); 924 + #[cfg(feature = "cache")] 925 + let resolver = resolver.with_cache(); 913 926 resolver 914 927 } 915 928 } ··· 923 936 let resolver = JacquardResolver::new(http, opts); 924 937 #[cfg(feature = "dns")] 925 938 let resolver = resolver.with_system_dns(); 939 + #[cfg(feature = "cache")] 940 + let resolver = resolver.with_cache(); 926 941 resolver 927 942 } 928 943