product: ship Sky Cache bounded TTL/CAS service - #1
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:d15e262ca6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| while len(self._entries) > self._max_entries: | ||
| self._entries.popitem(last=False) | ||
| self._stats["evictions"] += 1 |
There was a problem hiding this comment.
Purge expired entries before LRU eviction
When the cache is full and an expired entry is newer in the LRU order than a live entry, inserting another value pops the live entry here while retaining the expired one. For example, with capacity two, inserting live, then a zero-TTL expired, then new evicts live; the next purge removes expired and leaves the cache unnecessarily under capacity. Remove expired entries before choosing a live LRU victim.
Useful? React with 👍 / 👎.
| def get_value(key: str) -> dict[str, Any]: | ||
| entry = cache.get_entry(key) |
There was a problem hiding this comment.
Convert GET key validation failures to client errors
For GET requests whose decoded key is whitespace-only or exceeds 512 characters, get_entry() raises ValueError, but this handler does not translate it to an HTTPException as the PUT and DELETE handlers do. Such client-controlled input therefore escapes as a server error instead of returning a 4xx response.
Useful? React with 👍 / 👎.
Uh oh!
There was an error while loading. Please reload this page.
Product #13 of the SKYCOIN4444 standalone-product master plan.
This release candidate turns the existing local cache into a truthful standalone product: bounded thread-safe LRU storage, monotonic TTL expiration, set-if-absent, optimistic compare-and-set versions, metrics, FastAPI health/readiness/cache APIs, bounded JSON values, optional bearer authentication, deterministic tests, modern Python 3.12 dependencies, dependency audit and a non-root health-checked container.
Truthful boundary: this is a single-process ephemeral cache. It does not claim Redis compatibility, persistence, replication, distributed consensus, cross-node invalidation, HA, or multi-region consistency. Merge only after the exact PR head passes compile, Ruff, pytest, pip-audit, Docker build and non-root image verification.