Conversation
…perf + docs API redesign - Replaced TTLCache/SWRCache/BGCache class-based API with two symbols: cache() and bg - @cache(ttl, key=, stale=, store=, metrics=) — TTL and SWR in one decorator - @bg(interval, key=, ...) — background refresh decoupled from request path - bg.write / bg.read — single-writer / multi-reader cross-process pattern - Smart key templates: static 'flags', positional 'user:{}', named 'user:{user_id}' - .invalidate(*args) and .clear() on every decorated function Serializers - New serializers module: Serializer protocol, pack_entry/unpack_entry - Built-in: json (orjson), pickle, msgpack, protobuf(MyClass) - Pluggable to all byte-serializing backends (Redis, LocalFile, S3, GCS) - Custom serializer: implement dumps(v) -> bytes + loads(b) -> object Storage backends updated - InMemCache: __slots__, lock-free hot path (GIL atomicity), simplified API - RedisCache, LocalFileCache, S3Cache, GCSCache: all use pack_entry/unpack_entry - ChainCache.build(*stores, ttls=[...]) — N-level read-through - InstrumentedStorage.get_entry forwards optional now= param Performance - 23% throughput improvement (91ms -> 69ms per 100k calls) - TTL-only and SWR code paths split at decoration time (no runtime branch) - Single time.time() call per cache hit - Lock-free InMemCache reads; lock only on stale eviction - bg.read() local hit: ~9M ops/s bg writer/reader bug fixes (5 bugs) - Reader job ID collision: unique IDs per bg.read() via _reader_counter - bg.write and bg.read both missing metrics= parameter — added - bg.read(store=None) now auto-discovers writer's store in same process - asyncio.Lock was lazily initialized inside coroutine — fixed to init at registration - bg.write refresh loop never called metrics.record_background_refresh() — fixed Docs and examples - README.md: strong intro, full API reference with examples, single Mermaid diagram - docs/guide.md: 1022-line unified guide with Mermaid diagrams for every concept - Deleted 5 stale doc files using old API - 4 new runnable examples: quickstart, writer_reader, serializers, metrics - tests/benchmark.py and tests/profile_decorators.py rewritten for new API - 101 tests passing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
API redesign
Serializers
Storage backends updated
Performance
bg writer/reader bug fixes (5 bugs)