Skip to content

fix(cache): prevent bloom filter from rejecting reads on existing caches#20

Merged
indexzero merged 1 commit intomainfrom
fix/bloomfilter
Feb 1, 2026
Merged

fix(cache): prevent bloom filter from rejecting reads on existing caches#20
indexzero merged 1 commit intomainfrom
fix/bloomfilter

Conversation

@indexzero
Copy link
Copy Markdown
Owner

Summary

  • Fixed bloom filter incorrectly blocking all reads from existing caches
  • Added _bloomPopulated flag that tracks whether the bloom filter has been populated via set() operations
  • Bloom filter checks in fetch() and has() now only apply when the flag is true

Problem

When opening an existing cache, the bloom filter was empty (not loaded from persisted data). This caused cache.fetch(key) to return null for all keys because the empty bloom filter reported they didn't exist.

Solution

Only use the bloom filter for negative lookups when it has been populated during this session. This allows reads from existing caches to work correctly while still benefiting from bloom filter optimization for keys added during the current session.

Test plan

  • Existing cache tests pass (70 tests)
  • Verified cache export command works on existing cache data

🤖 Generated with Claude Code

The bloom filter was incorrectly blocking all reads from existing caches
because it was empty on startup - it wasn't populated from the persisted
cache data.

Added _bloomPopulated flag that is only set to true when keys are added
via set(). The bloom filter check in fetch() and has() now only applies
when this flag is true, allowing reads from existing caches to work.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@indexzero indexzero merged commit 18f8ff9 into main Feb 1, 2026
1 check passed
@indexzero indexzero deleted the fix/bloomfilter branch February 2, 2026 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant