28 lines
965 B
Plaintext
28 lines
965 B
Plaintext
=== STALE READ EXPERIMENT (трек 5.1) ===
|
|
|
|
BUG MODE (invalidation OFF):
|
|
|
|
1. Redis cache populated from GET /messages:
|
|
Key: messages:aa29af3d-b946-4358-b7e6-eb6aedaf1ee0:
|
|
Value: 50 items (seed 1..50)
|
|
|
|
2. POST STALE_1 → 201 Created.
|
|
DB has STALE_1: 1
|
|
|
|
3. Cache still contains OLD page (without STALE_1):
|
|
items in cache: 50
|
|
STALE_1 in cache: 0
|
|
|
|
CONCLUSION:
|
|
- DB has STALE_1 = 1
|
|
- Cache has STALE_1 = 0
|
|
- Client reads from cache → does NOT see own message
|
|
- STALE READ CONFIRMED
|
|
|
|
FIXED MODE (invalidation ON):
|
|
|
|
MessageService.Send вызывает MessageCache.Invalidate(chatID) при флаге invalidate=true.
|
|
Инвалидация удаляет все ключи messages:{chatID}:* из Redis.
|
|
Следующий GET /messages идёт в БД и возвращает свежие данные.
|
|
|
|
Защита реализована в коде: internal/repository/redis/message_cache.go, метод Invalidate. |