src.common.cache

Caching utilities for performance optimization in the Wordle Solver.

Functions

cache_pattern_calculation(func)

Decorator to cache pattern calculation results.

cache_strategy_results(func)

Decorator to cache strategy calculation results.

cache_word_frequency(func)

Decorator to cache word frequency calculations.

cached_word_pattern(guess, target)

Cached version of word pattern calculation.

clear_all_caches()

Clear all performance caches.

get_cache_stats()

Get statistics about cache usage.

Classes

TTLCache([max_size, ttl_seconds])

Time-to-live cache implementation.

class src.common.cache.TTLCache(max_size=128, ttl_seconds=300)[source]

Time-to-live cache implementation.

__init__(max_size=128, ttl_seconds=300)[source]
get(key)[source]

Get value from cache if not expired.

Return type:

Optional[Any]

set(key, value)[source]

Set value in cache with current timestamp.

Return type:

None

clear()[source]

Clear all cache entries.

Return type:

None

size()[source]

Get the current size of the cache (public method).

Return type:

int

src.common.cache.cache_word_frequency(func)[source]

Decorator to cache word frequency calculations.

Return type:

Callable[..., TypeVar(T)]

src.common.cache.cache_strategy_results(func)[source]

Decorator to cache strategy calculation results.

Return type:

Callable[..., TypeVar(T)]

src.common.cache.cache_pattern_calculation(func)[source]

Decorator to cache pattern calculation results.

Return type:

Callable[..., TypeVar(T)]

src.common.cache.cached_word_pattern(guess, target)[source]

Cached version of word pattern calculation. This is the most frequently called function in strategy calculations.

Return type:

str

src.common.cache.clear_all_caches()[source]

Clear all performance caches.

Return type:

None

src.common.cache.get_cache_stats()[source]

Get statistics about cache usage.

Return type:

Dict[str, Dict[str, Any]]