perf: use UNLINK instead of DEL in SearchIndex.drop_keys
Summary
currently uses , which reclaims memory synchronously on the main thread. For large key deletions (10K–1M+ keys), this causes visible latency spikes.
This PR switches to , which queues memory reclamation on a background thread, returning immediately to the caller.
Changes
- **sync ** (): →
- **async ** (): →
Context
This is the same optimization pattern already applied to in #613, now extended to .
Closes #600.
[!NOTE] Low Risk Low risk behavior-preserving change that swaps
DELforUNLINKin cache/index key removal paths; main risk is environments using Redis versions withoutUNLINKsupport.Overview Switches key-removal operations from
DEL/deleteto RedisUNLINKto make large deletions non-blocking.This updates
EmbeddingsCachedrop helpers (drop_by_key,mdrop_by_keys,adrop_by_key,amdrop_by_keys) andSearchIndex/AsyncSearchIndexdrop_keysto unlink keys asynchronously, with a small docstring note added inEmbeddingsCache.drop_by_key.Reviewed by Cursor Bugbot for commit 1ab884671d98e823f4b7bce39d88bca9aca29048. Bugbot is set up for automated code reviews on this repo. Configure here.