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:
@@ -19,6 +19,7 @@ CAPABILITIES = (
|
||||
"messages",
|
||||
"pagination",
|
||||
"data-storage",
|
||||
"chat-cache",
|
||||
"health",
|
||||
)
|
||||
SCENARIO_RE = re.compile(r"^#### Scenario: (.+?)\s*$", re.MULTILINE)
|
||||
@@ -47,6 +48,41 @@ EXCLUDED: dict[Scenario, Exclusion] = {
|
||||
check="тот же ручной сбой, затем make logs: запись error с "
|
||||
"traceback и тем же request_id",
|
||||
),
|
||||
("chat-cache", "Чтение из кэша"): Exclusion(
|
||||
reason="по HTTP ответ из кэша не отличить от ответа из PostgreSQL",
|
||||
check="idx_scan таблицы chats и keyspace_hits Valkey за 50 "
|
||||
"чтений — evidence/cache/hits.md",
|
||||
),
|
||||
("chat-cache", "Срок записи"): Exclusion(
|
||||
reason="срок ключа виден только в Valkey",
|
||||
check="TTL ключа карточки через valkey-cli — evidence/cache/hits.md",
|
||||
),
|
||||
("chat-cache", "Valkey остановлен"): Exclusion(
|
||||
reason="нужно остановить Valkey, тесты стенд не трогают",
|
||||
check="evidence/cache/outage.md; автоматическая проверка — "
|
||||
"change failure-checks",
|
||||
),
|
||||
("chat-cache", "Valkey завис"): Exclusion(
|
||||
reason="нужен docker compose pause для Valkey",
|
||||
check="evidence/cache/outage.md: время ответа; автоматическая "
|
||||
"проверка — change failure-checks",
|
||||
),
|
||||
("chat-cache", "Valkey вернулся"): Exclusion(
|
||||
reason="нужно остановить и снова запустить Valkey",
|
||||
check="evidence/cache/outage.md: warning и info в журнале, "
|
||||
"ключи снова пишутся; автоматическая проверка — change "
|
||||
"failure-checks",
|
||||
),
|
||||
("chat-cache", "Очистка кэша"): Exclusion(
|
||||
reason="нужен FLUSHALL в Valkey, тесты стенд не трогают",
|
||||
check="evidence/cache/flush-restart.md",
|
||||
),
|
||||
("chat-cache", "Временная база"): Exclusion(
|
||||
reason="ключи видны только в Valkey, а набор не знает, на какой "
|
||||
"базе работает",
|
||||
check="число ключей с префиксами рабочей и тестовой базы после "
|
||||
"make test_isolated — evidence/cache/hits.md",
|
||||
),
|
||||
("data-storage", "Прежний пользователь после рестарта"): Exclusion(
|
||||
reason="нужен рестарт стенда, тесты сервер не трогают",
|
||||
check="make test-persistence ACTION_SCRIPT=scripts/restart.sh: "
|
||||
@@ -80,6 +116,11 @@ EXCLUDED: dict[Scenario, Exclusion] = {
|
||||
"/health/live — 200; автоматическая проверка — change "
|
||||
"failure-checks",
|
||||
),
|
||||
("health", "Кэш недоступен"): Exclusion(
|
||||
reason="нужно остановить Valkey, тесты стенд не трогают",
|
||||
check="evidence/cache/outage.md: /health/ready — 200; "
|
||||
"автоматическая проверка — change failure-checks",
|
||||
),
|
||||
("identification", "Кнопка Authorize в Swagger"): Exclusion(
|
||||
reason="это интерфейс /docs в браузере",
|
||||
check="схемы bearerAuth и basicAuth, из которых строится кнопка, "
|
||||
|
||||
Reference in New Issue
Block a user