Skip to content

Add Prefix-Based Iteration Stopping to Cache#25

Merged
Menziess merged 4 commits intoMenziess:masterfrom
OnerInce:add-iterator-stopper
Feb 10, 2026
Merged

Add Prefix-Based Iteration Stopping to Cache#25
Menziess merged 4 commits intoMenziess:masterfrom
OnerInce:add-iterator-stopper

Conversation

@OnerInce
Copy link
Copy Markdown
Contributor

@OnerInce OnerInce commented Feb 9, 2026

Add Prefix-Based Iteration Stopping to Cache

What changed?

Added new prefix parameter to iteration methods in Cache class. This parameter makes iteration stop when key no longer starts with prefix.

Methods changed:

  • items()
  • keys()
  • values()
  • columns()
  • entities()

How to use:

cache['user:1'] = 'alice'
cache['user:2'] = 'bob'
cache['order:1'] = 'order1'

# Get only keys that start with 'user:'
list(cache.keys(prefix='user:'))  # ['user:1', 'user:2']

# Get only keys that start with 'order:'
list(cache.keys(prefix='order:'))  # ['order:1']

Tests

Added 8 new tests for prefix functionality. All 21 cache tests pass.

Breaking change?

No. Old code works same way. New parameter is optional and default is None.

@Menziess Menziess merged commit 3f1b285 into Menziess:master Feb 10, 2026
1 check passed
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.

2 participants