Skip to content

fix: use an LRU cache for cached patterns#60

Merged
andreasvc merged 1 commit into
andreasvc:masterfrom
blemoallic:fix/use_lru_cache
Jun 2, 2026
Merged

fix: use an LRU cache for cached patterns#60
andreasvc merged 1 commit into
andreasvc:masterfrom
blemoallic:fix/use_lru_cache

Conversation

@blemoallic

@blemoallic blemoallic commented Jun 2, 2026

Copy link
Copy Markdown

Description

Previously cache used was a LIFO cache: when cache size were > _MAXCACHE, we used _cache.popitem() that removes the 1st element of the cache and then _cache[cachekey] = p to add element to cache, that add the item to the top of the cache.

This PR introduces OrderedDict for cache management and changes LIFO behaviour to LRU.

Closes #59

@blemoallic
blemoallic force-pushed the fix/use_lru_cache branch from 335b697 to c8dad26 Compare June 2, 2026 08:34
@andreasvc
andreasvc merged commit c61d1aa into andreasvc:master Jun 2, 2026
12 of 17 checks passed
@andreasvc

Copy link
Copy Markdown
Owner

Thanks!

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.

Is there a reason to use a LIFO for compiled pattern cache ?

2 participants