feat: Enhance autocomplete cache with async initialization and improved eviction logic
Based on discussion #8315 Implement asynchronous initialization for the autocomplete cache and refine eviction logic to optimize performance and memory usage. This update ensures a more efficient handling of cached entries with SQLite persistence.
Summary by cubic
Initialize the autocomplete cache asynchronously and move lookups to an in-memory LRU with periodic SQLite persistence. This improves startup, speeds up cache hits, and tightens eviction for better memory usage.
-
New Features
- Async singleton cache initialization that loads existing entries and starts a 30s flush timer.
- In-memory longest-prefix matching with validation; timestamps updated on access.
- LRU eviction in memory when capacity is exceeded, marking evicted keys for deletion.
- Periodic flush persists dirty entries in a single transaction (upsert/delete) under a mutex, with graceful error handling.
- CompletionProvider now awaits the cache on demand and disposes it cleanly via close().
- Added comprehensive tests for cache operations, eviction, persistence, timer behavior, and resource cleanup.
@Ayyanaruto appreciate this contribution!
Pleasure is all mine
:tada: This PR is included in version 1.5.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
:tada: This PR is included in version 1.31.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
:tada: This PR is included in version 1.35.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
:tada: This PR is included in version 1.6.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket: