pub struct CircuitCache { /* private fields */ }Expand description
Thread-safe LRU cache for compiled FHE circuits.
Cloning a CircuitCache produces a second handle that shares the same
underlying cache, making it cheap to hand out per-request copies.
§Example
let cache = CircuitCache::new(CircuitCacheConfig::default());
let circuit = cache.get_or_compile(&predicate, || {
let mut compiler = PredicateCompiler::new();
compiler.compile(&predicate, EncryptedType::U8)
})?;Implementations§
Source§impl CircuitCache
impl CircuitCache
Sourcepub fn new(config: CircuitCacheConfig) -> Self
pub fn new(config: CircuitCacheConfig) -> Self
Create a new cache with the given configuration.
Sourcepub fn get(&self, key: &CircuitCacheKey) -> Option<Circuit>
pub fn get(&self, key: &CircuitCacheKey) -> Option<Circuit>
Look up a pre-computed cache key in the cache.
Returns Some(Circuit) on a hit or None on a miss.
Sourcepub fn insert(&self, key: CircuitCacheKey, circuit: Circuit)
pub fn insert(&self, key: CircuitCacheKey, circuit: Circuit)
Insert a compiled circuit into the cache.
If the key is already present the call is a no-op.
Sourcepub fn get_or_compile<F>(
&self,
predicate: &Predicate,
compile_fn: F,
) -> Result<Circuit>
pub fn get_or_compile<F>( &self, predicate: &Predicate, compile_fn: F, ) -> Result<Circuit>
Get a cached circuit or compile it on a miss.
On a cache miss compile_fn is called exactly once to produce the
circuit, which is then stored before being returned. On a cache hit
compile_fn is never called.
§Errors
Returns the error produced by compile_fn on a miss if compilation
fails. Cache hits never return an error from this method.
Sourcepub fn stats(&self) -> CircuitCacheStats
pub fn stats(&self) -> CircuitCacheStats
Return a point-in-time snapshot of the cache statistics.
Trait Implementations§
Source§impl Clone for CircuitCache
impl Clone for CircuitCache
Source§fn clone(&self) -> CircuitCache
fn clone(&self) -> CircuitCache
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for CircuitCache
impl !UnwindSafe for CircuitCache
impl Freeze for CircuitCache
impl Send for CircuitCache
impl Sync for CircuitCache
impl Unpin for CircuitCache
impl UnsafeUnpin for CircuitCache
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.