Skip to content

Conversation

@agkloop
Copy link
Owner

@agkloop agkloop commented Dec 15, 2025

This pull request introduces several new features and improvements to the advanced_caching library, focusing on enhanced Redis serialization flexibility, easier hybrid cache setup, and better test coverage. The most significant changes are the addition of pluggable serializers for RedisCache, a new helper for streamlined hybrid cache creation, independent TTL control for cache layers, and expanded documentation and tests.

Core enhancements:

  • RedisCache Serialization:
    • RedisCache now supports pluggable serializers, allowing users to choose between built-in pickle (default), json, or provide custom serializer objects. This is implemented via a new Serializer protocol and the PickleSerializer and JsonSerializer classes. The serialization logic automatically wraps or unwraps cache entries as needed. (src/advanced_caching/storage.py, src/advanced_caching/__init__.py) [1] [2] [3] [4] [5] [6] [7] [8] [9]
  • HybridCache Improvements:
    • Added a l2_ttl parameter to HybridCache for independent control of the L2 (Redis) TTL, defaulting to twice the L1 TTL if not specified. All relevant methods now respect this parameter. (src/advanced_caching/storage.py) [1] [2] [3] [4]
    • Introduced a HybridCache.from_redis helper (documented in the changelog) for simplified L1+L2 cache setup.

Testing and documentation:

  • Expanded Test Coverage:
    • Added comprehensive tests for the BGCache lambda cache factory pattern and for the new HybridCache l2_ttl behavior, ensuring correct instantiation and cache operation. (tests/test_correctness.py)
  • Documentation and Metadata:
    • Updated CHANGELOG.md with a new release section summarizing these features and improvements. (CHANGELOG.md)
    • Exposed __version__ and new serializer classes in the main module for easier version checking and import. (src/advanced_caching/__init__.py) [1] [2]
    • Removed the GITHUB_ACTIONS.md setup guide, as it is no longer needed. (GITHUB_ACTIONS.md)
    • Removed an obsolete test file. (tests/test.py)

Summary of most important changes:

Serialization and cache flexibility:

  • RedisCache now supports pluggable serializers with built-ins for pickle (default) and json, plus custom dumps/loads implementations. (src/advanced_caching/storage.py, src/advanced_caching/__init__.py) [1] [2] [3] [4] [5] [6] [7] [8] [9]
  • HybridCache now supports an l2_ttl parameter for independent L2 TTL control, defaulting to l1_ttl * 2 if not specified. (src/advanced_caching/storage.py) [1] [2] [3] [4]
  • Added HybridCache.from_redis helper for easy L1+L2 setup (documented in changelog). (CHANGELOG.md)

Testing and documentation:

  • Comprehensive test coverage for BGCache lambda cache factory pattern and HybridCache l2_ttl behavior. (tests/test_correctness.py)
  • Documentation and metadata improvements: updated changelog, exposed __version__, removed obsolete files. (CHANGELOG.md, src/advanced_caching/__init__.py, GITHUB_ACTIONS.md, tests/test.py) [1] [2] [3] [4] [5]

@agkloop agkloop merged commit 018672f into main Dec 15, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants