Skip to content

Feat/cache store - #70

Merged
Iamsdt merged 5 commits into
mainfrom
feat/cache-store
Nov 1, 2026
Merged

Iamsdt merged 5 commits into
mainfrom
feat/cache-store

Conversation

@Iamsdt

@Iamsdt Iamsdt commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fourth 1.0 release candidate. Everything the API shares between workers now lives in
one BaseCacheStore, configured by one cache_store object in 10xgraph.json. Fixes the
rc3 bug where a leftover REDIS_URL stopped an in-memory server from booting in
production. Requires 10xgraph>=1.0.0rc4.

Breaking

  • Removed (no aliases, release candidates): ConcurrencyLimiter, TokenRevocationBackend
    and its variants, BaseRateLimitBackend, MemoryRateLimitBackend, RedisRateLimitBackend.
  • New cache_store object: {"type": "memory"|"redis"|"custom", "url", "path", "rate_limit", "token_revocation"}. No cache_store means the in-memory store.
  • Top-level redis, rate_limit and token_revocation keys are config errors that say
    where each setting goes.
  • REDIS_URL no longer selects the cache store; Settings.REDIS_URL is gone.
    "type": "redis" with no url reads REDIS_URL.
  • type: "redis" without the redis package refuses to boot (no silent per-process fallback).
  • /health/ready: checks.redis renamed checks.cache. Readiness and the startup check
    only call aping() on the checkpointer, store and cache store.
  • Rate-limit Redis keys moved to 10xgraph:ratelimit2, so counters reset once at deploy.
    Lock key layout unchanged, so old and new pods share locks during a rolling deploy.
  • 10xgraph init asks only name, template and provider. Production writes jwt auth,
    ownership authorization, uuid ids and a Redis cache store with rate limit and token
    revocation. Flags override parts of it for scripts.
  • thread_name_generator: random (default, now saved), first_message, none or
    module:attr. GraphConfig.thread_name_generator_path replaced by thread_name_generator.

Added

  • BaseCacheStore, RedisCacheStore (also Valkey, Dragonfly, KeyDB), InMemoryCacheStore,
    exported from tenxgraph_api; optional describe() names the endpoint in logs and errors.
  • Contract suite for custom stores: tenxgraph_api.testing.cache_store_contract.
  • id_generator key: uuid, hex, short, int, bigint, timestamp, snowflake or module:attr.
  • thread_name_generator: "first_message".
  • 10xgraph config: token revocation section and a Cache store page.

Changed

  • The cache store is fatal at boot only for fail-closed features (token revocation with
    auth, or rate limiting with fail_open: false); otherwise one WARNING and the server starts.
  • Locks, caps, idempotency and the ownership cache fail open; revocation fails closed (503);
    rate limiting follows fail_open.
  • 10xgraph revoke writes to the selected cache store and refuses on the in-memory store.
  • Shutdown closes the cache store once, after the graph and pending lease releases.
  • In-memory store uses the monotonic clock for expiries; revoke_user rounds the cutoff up.

Fixed

  • A leftover REDIS_URL no longer blocks boot when nothing configured needs Redis.
  • A rate-limit denial stays 429 when reading the store clock for Retry-After fails.

Before merge

  • Core floor bumped to 10xgraph>=1.0.0rc4 and uv lock refreshed (after core rc4 is on PyPI).

Tests

  • Contract suite against InMemoryCacheStore; startup check, readiness, init and revoke tests.
  • Not yet run: contract suite against a real Redis (TEST_REDIS_URL).

…r and InMemoryCacheStore

- Replaced MemoryConcurrencyLimiter with LeaseManager in stream thread naming tests.
- Updated test_thread_lock.py to utilize LeaseManager for concurrency limits.
- Refactored token revocation tests to use InMemoryCacheStore instead of InMemoryTokenRevocation and RedisTokenRevocation.
- Adjusted websocket guard tests to implement LeaseManager for connection limits.
- Enhanced websocket limits tests to share the bound cache store for rate limiting and connection management.
- Removed unused thread name generator path from service configuration in test_stream_thread_naming.py.
- Updated thread name generator path handling in test_thread_lock.py.
- Modified token revocation handling in test_token_revocation.py to use cache_store.
- Adjusted rate limit configuration in test_websocket_guard.py to include a cap.
- Added comprehensive tests for cache_store configuration in test_cache_store_config.py.
- Introduced tests for id_generator configuration in test_id_generator_config.py.
- Created tests for thread name generator choices in test_thread_name_choices.py.
- Updated the `init` command to streamline project initialization by reducing interactive prompts.
- Simplified the configuration for quick-start and production templates, focusing on essential parameters.
- Introduced new flags for cache store options (`--cache-store`), rate limiting (`--rate-limit`), and token revocation (`--token-revocation`).
- Adjusted the generated `10xgraph.json` to reflect changes in cache store handling, removing unnecessary URL fields for Redis.
- Enhanced documentation to clarify the new command behavior and options.
- Updated tests to cover new configurations and ensure backward compatibility.
@Iamsdt
Iamsdt merged commit a55eaf6 into main Nov 1, 2026
9 checks passed
@Iamsdt
Iamsdt deleted the feat/cache-store branch November 1, 2026 10:27
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.

1 participant