Skip to main content

start_eviction_loop

Function start_eviction_loop 

Source
pub fn start_eviction_loop(
    store: Arc<SqliteStore>,
    config: &EvictionConfig,
    policy: Arc<dyn EvictionPolicy + 'static>,
    cancel: CancellationToken,
) -> JoinHandle<()>
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 and attempts to remove their Qdrant vectors. If Qdrant removal fails, it is retried on the next sweep cycle.

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

ยงErrors (non-fatal)

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