pub struct IndexCache { /* private fields */ }Expand description
Lockfree-ish process cache of loaded indexes.
Implementations§
Source§impl IndexCache
impl IndexCache
Sourcepub fn new(model: StaticModel) -> Self
pub fn new(model: StaticModel) -> Self
Build a cache with the default capacity (DEFAULT_CACHE_SIZE).
Sourcepub fn with_capacity(model: StaticModel, capacity: usize) -> Self
pub fn with_capacity(model: StaticModel, capacity: usize) -> Self
Build a cache with an explicit capacity.
Sourcepub async fn get_or_load(
&self,
repo: &str,
include_text_files: bool,
) -> Result<Arc<RwLock<VelesIndex>>>
pub async fn get_or_load( &self, repo: &str, include_text_files: bool, ) -> Result<Arc<RwLock<VelesIndex>>>
Get or lazily build the VelesIndex for repo.
Returns an Arc<RwLock<VelesIndex>> the caller can .read() or
.write() independently of the cache lock. Multiple concurrent
loaders of the same repo share a single in-flight build via the
internal OnceCell.
repo is either a local directory path or an https:// git URL.
Local paths prefer the persisted .veles/ index when one exists
(fast load) and fall back to a fresh in-memory build otherwise.
Sourcepub fn peek(&self, repo: &str) -> Option<Arc<RwLock<VelesIndex>>>
pub fn peek(&self, repo: &str) -> Option<Arc<RwLock<VelesIndex>>>
Look up repo without building. Returns Some only if the
cell has been initialised (i.e. a previous get_or_load for
this repo has completed successfully). Used by callers that
want to gate on “is this repo bootstrapped yet?” without
triggering an expensive build — e.g. the gRPC GetStats RPC.
Sourcepub fn invalidate(&self, repo: &str) -> bool
pub fn invalidate(&self, repo: &str) -> bool
Drop the cached entry for repo if present. Useful for tests
and explicit invalidation.
Auto Trait Implementations§
impl !Freeze for IndexCache
impl !RefUnwindSafe for IndexCache
impl Send for IndexCache
impl Sync for IndexCache
impl Unpin for IndexCache
impl UnsafeUnpin for IndexCache
impl !UnwindSafe for IndexCache
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
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 more