🚧 Developing
-
💔 Breaking Changes:
-
Constructor parameter rename: the Redis client parameters have been renamed to
clientandfactory(keyword-only).factoryis preferred for concurrent/production usage. -
Policy must be an instance: the
policyargument toRedisFuncCachenow requires a pre-instantiatedAbstractPolicyinstance (e.g.LruTPolicy()), previously callers might have passed the policy class. -
Passing a callable as the
clientpositional argument is deprecated. Usefactory=instead. The library will emit aDeprecationWarningwhen 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
clientpositional argument. If you want, I can scan the repository for remaining occurrences and update examples/tests accordingly.
-
- 💔 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
📅 2025-08-26
-
✨ New Features:
- Added arguments excluding support for the
RedisFuncCacheclass, which makes it possible to cache functions with arguments that cannot be serialized. - Added support for controlling cache TTL update behavior with
update_ttlparameter. - Enhanced cache mode control with mode context managers:
RedisFuncCache.mode_context()for applying mode contextuallyRedisFuncCache.disable_rw()as an alias for completely disabling cache read and write operationsRedisFuncCache.read_only()for read-only cache modeRedisFuncCache.write_only()for write-only cache mode
- Added new
RedisFuncCache.Statsclass for cache statistics, andRedisFuncCache.stats_context()for retrieving cache statistics in a context manager. - Added support for per-invocation's cache TTL(experimental).
- Added
use_bytecodeattribute toHashConfigclass.
- Added arguments excluding support for the
-
💔 Breaking Changes:
- Rename
redis_func_cache.mixins.policiestoredis_func_cache.mixins.scripts. - Remove
asynchronousproperty 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.
- Rename
-
👎 Deprecated:
- The property
RedisFuncCache.cacheis deprecated, useRedisFuncCache.get_cache()instead
- The property
-
🛠 Improvements:
- Optimized Lua scripts for better performance
- Improved documentation and examples for cache mode control
- Enhanced test coverage for new cache mode context managers
📅 2025-06-24
-
✨ New Features:
- Added
bsonandyamlserializer/deserializer support for theRedisFuncCacheclass. - 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).
- Added
-
💔 Breaking Changes:
- The
serializeroptional parameter in theRedisFuncCache'sdecorateand__call__methods has been replaced. It now accepts a tuple of(serializer, deserializer)or simply the name of the serializer function.
- The
-
🛠 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
pygmentsor Lua lexer more gracefully, and marks these branches as uncovered for coverage tools.
-
📦 Packaging:
- Added
bson,yamlas optional dependencies, andallfor all serializers. - Added
types-all,types-PyYAML, andtypes-Pygmentsas optional dependencies for typing hints. - Build and dependency management migrated to uv.
- Added
-
📝 Misc
- Minor adjustments to documentation and configuration files.
📅 2025-01-08
-
✨ New Features:
- Added setter methods for the
name,prefix,maxsize,ttl, andserializerproperties in theRedisFuncCacheclass. - Introduced support for
msgpackandcloudpickle. - Added "per-function" custom serializer/deserializer parameter to
RedisFuncCache's decorate method.
- Added setter methods for the
-
💔 Breaking Changes:
- Moved the
lru-tpolicy class to thepolicies/lrumodule. - Moved the
fifo-tpolicy class to thepolicies/fifomodule. - Renamed
sizetoget_sizeandasizetoaget_sizeinAbstractPolicyand its subclasses.
- Moved the
-
💹 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
RedisFuncCacheconstructor. - Improved type casting in the
cachemodule.
-
📦 Packaging:
- Added
msgpackandcloudpickleas optional dependencies. - Adjusted the
manifest.infile.
- Added
-
🧪 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
codecovcoverage upload. - Removed PyPy testing from
tests/run.sh.
📅 2024-12-23
-
✨ New Features:
- New
fifo-t(Timestamp based pseudo FIFO replacement policy)
- New
-
🐛 Bug Fixes:
- Wrong type checking for
redis.cluster.RedisClusterandredis.asyncio.cluster.RedisCluster
- Wrong type checking for
-
🛠 Improvements:
- Remove some un-used utilities
-
📦 Packaging:
- Add
hiredisextras requirements - Adjust
manifest.infile
- Add
-
📚 Documentation:
- Modify documentation for docker-composed unit testing
-
🧪 Tests:
- New add cluster based tests
- Improved docker-composed based tests
📅 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.
📅 2024-12-17
The First release, it's an early version, do not use it in production.