Skip to content

Release v6.0.0

Choose a tag to compare

@awolverp awolverp released this 02 Jun 11:46
· 6 commits to main since this release

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 postprocess parameter to the @cached decorator, providing much more flexible control over cached results (replaces the deprecated copy_level).
  • Added getsizeof parameter to cache classes. This callable allows implementing weighted caching based on memory footprint, object size, or any custom logic.
  • Background sweeping support for TTLCache and VTTLCache via the new sweep_interval parameter. 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 FIFOCache and TTLCache.
  • 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.
  • @cached decorator now uses LRUCache by default, instead of FIFOCache.

Breaking Changes

  • copy_level parameter in @cached has been deprecated and no longer has any effect.
  • TTLCache.ttl has been renamed to TTLCache.global_ttl to avoid confusion with per-item TTL.
  • cachedmethod decorator has been completely removed (deprecated since v5.1.0).
  • maxmemory parameter has been removed due to severe performance regression. Use getsizeof for 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