feat: cache chat cards in Valkey
Valkey 9.1 in compose caches the immutable chat card (title, members,
created_at) used by GET /chats/{id} and by the membership check of the
message endpoints. Cache-aside with a write after commit, keys per
database, TTL plus allkeys-lru, persistence off. redis-py runs without
retries; on failure the cache is skipped for a few seconds and requests
go to PostgreSQL. Readiness does not depend on Valkey.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,9 +6,10 @@
|
||||
python3 .claude/skills/run-mtusi-messenger/driver.py [--port N] <cmd>
|
||||
|
||||
Команды:
|
||||
start `make upgrade` (Postgres из compose и миграции), затем поднять
|
||||
`python -m src` в фоне (console, reload) и дождаться
|
||||
/health/ready; лог и pid — /tmp/mtusi-api-<port>.{log,pid}
|
||||
start `make upgrade start_cache` (Postgres из compose и миграции,
|
||||
Valkey), затем поднять `python -m src` в фоне (console,
|
||||
reload) и дождаться /health/ready; лог и pid —
|
||||
/tmp/mtusi-api-<port>.{log,pid}
|
||||
status кто слушает порт и что отвечает /health/ready
|
||||
flow сквозной сценарий по HTTP с проверками; код выхода 1 при провале
|
||||
req один запрос: req METHOD PATH [--token T | --basic USER:PASS]
|
||||
@@ -135,16 +136,17 @@ def cmd_start(port: int) -> int:
|
||||
return 0
|
||||
print(f"port {port} is busy:", listener_pids(port))
|
||||
return 1
|
||||
# без Postgres сервис стартует, но /health/ready отвечает 503
|
||||
# без Postgres сервис стартует, но /health/ready отвечает 503; без
|
||||
# Valkey работает, но мимо кэша
|
||||
upgrade = subprocess.run(
|
||||
["make", "upgrade"],
|
||||
["make", "upgrade", "start_cache"],
|
||||
cwd=ROOT,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
if upgrade.returncode != 0:
|
||||
print("make upgrade failed:")
|
||||
print("make upgrade start_cache failed:")
|
||||
print((upgrade.stdout + upgrade.stderr)[-2000:])
|
||||
return 1
|
||||
env = os.environ | {"APP__RUN_MODE": "console", "APP__PORT": str(port)}
|
||||
|
||||
Reference in New Issue
Block a user