Skip to main content

start_eviction_loop

Function start_eviction_loop 

Source
pub async fn start_eviction_loop(
    store: Arc<SqliteStore>,
    embedding: Option<Arc<EmbeddingStore>>,
    config: EvictionConfig,
    policy: Arc<dyn EvictionPolicy + 'static>,
    cancel: CancellationToken,
)
Expand description

Start the background eviction loop.

The loop runs every config.sweep_interval_secs seconds. Each iteration:

  1. Queries SQLite for all non-deleted entries and their eviction metadata.
  2. Scores each entry using policy.
  3. If the count exceeds config.max_entries, soft-deletes the excess lowest-scoring rows.
  4. Queries for all soft-deleted rows, deletes their Qdrant vectors via embedding (when Some), then marks the rows clean. If deletion fails, clean-up is retried next sweep.

If config.max_entries == 0, the loop exits immediately without doing anything.

Pass embedding: None when Qdrant is disabled — the loop will still clean SQLite bookkeeping without attempting any vector deletion.

§Errors (non-fatal)

Database and Qdrant errors are logged but do not stop the loop.