pub enum CacheBackend {
InMemory,
File(FileCache),
Custom(Arc<dyn Cache>),
}Expand description
How a SimbadResolver obtains its cache backend.
The built-in variants select the redb-backed Store at
construction; Custom accepts any Cache. Backend tuning
lives on the variant that owns it (e.g. FileCache), so the constructor
signature never grows.
There is deliberately no “disabled” variant: the cache is load-bearing (the
resolve pipeline returns cached rows), so InMemory is the
ephemeral, nothing-persisted choice and is what Default selects. For a
truly uncached one-shot lookup, call a bare Resolver directly instead of
the facade.
use simbad_resolver::CacheBackend;
let ephemeral = CacheBackend::InMemory;
let durable = CacheBackend::file("targets.redb"); // opened lazily by `SimbadResolver::new`
assert!(matches!(ephemeral, CacheBackend::InMemory));
assert!(matches!(durable, CacheBackend::File(_)));Variants§
InMemory
Ephemeral in-memory redb store (nothing persisted to disk).
File(FileCache)
Durable, file-backed redb store.
Custom(Arc<dyn Cache>)
A caller-supplied cache backend.
Implementations§
Source§impl CacheBackend
impl CacheBackend
Sourcepub fn file(path: impl Into<PathBuf>) -> Self
pub fn file(path: impl Into<PathBuf>) -> Self
A file-backed backend at path with default options.
use simbad_resolver::CacheBackend;
let backend = CacheBackend::file("targets.redb"); // opened lazily by `SimbadResolver::new`
assert!(matches!(backend, CacheBackend::File(_)));Sourcepub fn custom(cache: impl Cache + 'static) -> Self
pub fn custom(cache: impl Cache + 'static) -> Self
Wrap a caller-supplied cache backend.
use simbad_resolver::{CacheBackend, Store};
// Any `Cache` impl works, e.g. a `Store`'s own `.cache()`.
let backend = CacheBackend::custom(Store::in_memory()?.cache());
assert!(matches!(backend, CacheBackend::Custom(_)));Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for CacheBackend
impl !UnwindSafe for CacheBackend
impl Freeze for CacheBackend
impl Send for CacheBackend
impl Sync for CacheBackend
impl Unpin for CacheBackend
impl UnsafeUnpin for CacheBackend
Blanket Implementations§
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
Mutably borrows from an owned value. Read more