CHANGELOG#

Changelog#

v0.7.0#

πŸ“… 2026-03-30

  • πŸ’” Breaking Changes:

    • Constructor parameter rename: the Redis client parameters have been renamed to client and factory (keyword-only). factory is preferred for concurrent/production usage.

    • Policy must be an instance: the policy argument to RedisFuncCache now requires a pre-instantiated AbstractPolicy instance (e.g. LruTPolicy()), previously callers might have passed the policy class.

    • Passing a callable as the client positional argument is deprecated. Use factory= instead. The library will emit a DeprecationWarning when detecting the old pattern.

    Migration example:

    # OLD
    cache = RedisFuncCache("my-cache", LruTPolicy, client=redis_client)
    
    # NEW (v0.7+)
    cache = RedisFuncCache("my-cache", LruTPolicy(), factory=lambda: redis.from_pool(redis.ConnectionPool(...)))
    
  • πŸ›  Notes:

    • The change to require policy instances was made to ensure policy objects can be bound to the cache (policies hold cache-specific state). Reuse of the same policy instance across multiple caches is discouraged; create a new policy object per cache if independent state is required.

    • Please update any code that relied on passing policy classes or that passed a callable as the client positional argument. If you want, I can scan the repository for remaining occurrences and update examples/tests accordingly.

v0.6.0#

  • πŸ’” Breaking Changes:

    • Drop support for Python 3.8

    • Upgrade build backend to setuptools>=80

  • πŸ›  Improvements:

    • Optimized cache eviction logic in Lua scripts to improve performance and correctness

    • Fixed issues with evicted keys handling in LRU cache implementation

    • Improved consistency in cache TTL handling across all cache policies

    • Simplified and unified code structure in all put scripts for better maintainability

    • Enhanced efficiency by replacing loops with batch operations in FIFO_T policy

  • πŸ› Bug Fixes:

    • Fixed LRU cache score update logic that could cause incorrect eviction order

    • Corrected cache access frequency update logic in LFU policy

    • Fixed timestamp update logic in LRU-T policy

    • Fixed wrong usages of table unpack in Lua scripts

  • 🧹 Chore:

    • Added Python 3.14 in CI and tests scripts

v0.5#

πŸ“… 2025-08-26

  • ✨ New Features:

    • Added arguments excluding support for the RedisFuncCache class, which makes it possible to cache functions with arguments that cannot be serialized.

    • Added support for controlling cache TTL update behavior with update_ttl parameter.

    • Enhanced cache mode control with mode context managers:

      • RedisFuncCache.mode_context() for applying mode contextually

      • RedisFuncCache.disable_rw() as an alias for completely disabling cache read and write operations

      • RedisFuncCache.read_only() for read-only cache mode

      • RedisFuncCache.write_only() for write-only cache mode

    • Added new RedisFuncCache.Stats class for cache statistics, and RedisFuncCache.stats_context() for retrieving cache statistics in a context manager.

    • Added support for per-invocation’s cache TTL(experimental).

    • Added use_bytecode attribute to HashConfig class.

  • πŸ’” Breaking Changes:

    • Rename redis_func_cache.mixins.policies to redis_func_cache.mixins.scripts.

    • Remove asynchronous property and related checks, you must ensure to decorate an async function with a cache instance has asynchronous redis client and a common function with a cache instance has synchronous redis client.

  • πŸ‘Ž Deprecated:

    • The property RedisFuncCache.cache is deprecated, use RedisFuncCache.get_cache() instead

  • πŸ›  Improvements:

    • Optimized Lua scripts for better performance

    • Improved documentation and examples for cache mode control

    • Enhanced test coverage for new cache mode context managers

v0.4#

πŸ“… 2025-06-24

  • ✨ New Features:

    • Added bson and yaml serializer/deserializer support for the RedisFuncCache class.

    • Added comprehensive unit tests for exception handling, unserializable objects, various argument types, cache purge, custom serializers, and high concurrency scenarios (multi-thread/thread pool/concurrent exception handling).

  • πŸ’” Breaking Changes:

    • The serializer optional parameter in the RedisFuncCache’s decorate and __call__ methods has been replaced. It now accepts a tuple of (serializer, deserializer) or simply the name of the serializer function.

  • πŸ›  Improvements:

    • Updated and optimized several Lua scripts to improve performance, reliability, and compatibility with Redis.

    • Refactored test code for better readability and maintainability.

    • Improved code style and type annotations across the codebase.

    • Improved Redis Lua script cleaning logic: now handles the absence of pygments or Lua lexer more gracefully, and marks these branches as uncovered for coverage tools.

  • πŸ“¦ Packaging:

    • Added bson, yaml as optional dependencies, and all for all serializers.

    • Added types-all, types-PyYAML, and types-Pygments as optional dependencies for typing hints.

    • Build and dependency management migrated to uv.

  • πŸ“ Misc

    • Minor adjustments to documentation and configuration files.

v0.3#

πŸ“… 2025-01-08

  • ✨ New Features:

    • Added setter methods for the name, prefix, maxsize, ttl, and serializer properties in the RedisFuncCache class.

    • Introduced support for msgpack and cloudpickle.

    • Added β€œper-function” custom serializer/deserializer parameter to RedisFuncCache’s decorate method.

  • πŸ’” Breaking Changes:

    • Moved the lru-t policy class to the policies/lru module.

    • Moved the fifo-t policy class to the policies/fifo module.

    • Renamed size to get_size and asize to aget_size in AbstractPolicy and its subclasses.

  • πŸ’Ή Improvements:

    • The default hash function now calculates the hash value based on the callable’s byte code instead of source code.

    • Updated the default values of several arguments in the RedisFuncCache constructor.

    • Improved type casting in the cache module.

  • πŸ“¦ Packaging:

    • Added msgpack and cloudpickle as optional dependencies.

    • Adjusted the manifest.in file.

  • πŸ§ͺ Tests:

    • Added more test cases.

    • Fixed asynchronous bugs in existing tests.

    • Optimized Docker Compose-based tests.

  • βš™οΈ CI:

    • Added Redis cluster tests in GitHub Actions.

    • Fixed issues with codecov coverage upload.

    • Removed PyPy testing from tests/run.sh.

v0.2.2#

πŸ“… 2024-12-23

  • ✨ New Features:

    • New fifo-t (Timestamp based pseudo FIFO replacement policy)

  • πŸ› Bug Fixes:

    • Wrong type checking for redis.cluster.RedisCluster and redis.asyncio.cluster.RedisCluster

  • πŸ›  Improvements:

    • Remove some un-used utilities

  • πŸ“¦ Packaging:

    • Add hiredis extras requirements

    • Adjust manifest.in file

  • πŸ“š Documentation:

    • Modify documentation for docker-composed unit testing

  • πŸ§ͺ Tests:

    • New add cluster based tests

    • Improved docker-composed based tests

v0.2.1#

πŸ“… 2024-12-19

  • ✨ New Features:

    • Added support for asynchronous operations.

  • πŸ› Bug Fixes:

    • Resolved several known issues.

    • Eliminated duplicate parts in the function full name used as a key.

  • πŸ›  Improvements:

    • Enhanced type hints for better code clarity.

    • Provided more detailed documentation to improve user understanding.

v0.1#

πŸ“… 2024-12-17

The First release, it’s an early version, do not use it in production.