Release v6.0.0
The library has been completely optimized and rewritten for maximum performance and stability. All core algorithms have been reviewed and improved, multiple long-standing bugs have been fixed, and several requested features have been added.
New Features
- Added
postprocessparameter to the@cacheddecorator, providing much more flexible control over cached results (replaces the deprecatedcopy_level). - Added
getsizeofparameter to cache classes. This callable allows implementing weighted caching based on memory footprint, object size, or any custom logic. - Background sweeping support for
TTLCacheandVTTLCachevia the newsweep_intervalparameter. When set, a background thread automatically cleans up expired items (#46). - New methods added to all cache classes:
current_size()remaining_size()contains()
- Added helper functions for better type hinting:
get_cached_cache()get_cached_cache_info()get_cached_callback()clear_cached_cache()
Changes
- The entire library is now implemented in Rust using PyO3. Python wrapper classes have been removed.
- Significant performance improvements (very large speed gains).
- Major algorithmic improvements to
FIFOCacheandTTLCache. - Tests has been expanded and improved for better coverage and reliability.
- All docstrings have been expanded with explanations of algorithms.
- Mimalloc allocator has been removed.
- All dependencies has been updated.
@cacheddecorator now usesLRUCacheby default, instead ofFIFOCache.
Breaking Changes
copy_levelparameter in@cachedhas been deprecated and no longer has any effect.TTLCache.ttlhas been renamed toTTLCache.global_ttlto avoid confusion with per-item TTL.cachedmethoddecorator has been completely removed (deprecated since v5.1.0).maxmemoryparameter has been removed due to severe performance regression. Usegetsizeoffor weighted caching instead.- Pickle states structure changed (
__getstate__/__setstate__). Pickled caches from v5 may not be compatible with v6.
Bug Fixes
Thanks To
Read Migration Guide