redis-vl-python icon indicating copy to clipboard operation
redis-vl-python copied to clipboard

perf: use UNLINK instead of DEL in SearchIndex.drop_keys

Open LizerAIDev opened this issue 6 months ago • 0 comments

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 DEL for UNLINK in cache/index key removal paths; main risk is environments using Redis versions without UNLINK support.

Overview Switches key-removal operations from DEL/delete to Redis UNLINK to make large deletions non-blocking.

This updates EmbeddingsCache drop helpers (drop_by_key, mdrop_by_keys, adrop_by_key, amdrop_by_keys) and SearchIndex/AsyncSearchIndex drop_keys to unlink keys asynchronously, with a small docstring note added in EmbeddingsCache.drop_by_key.

Reviewed by Cursor Bugbot for commit 1ab884671d98e823f4b7bce39d88bca9aca29048. Bugbot is set up for automated code reviews on this repo. Configure here.

LizerAIDev avatar May 14 '26 17:05 LizerAIDev