Лаба 2: PostgreSQL-хранилище и Redis-сессии (оценка 4)

FastAPI + asyncpg + Redis/argon2id. Пользователи/чаты/участники/сообщения
в Postgres с версионируемой миграцией и keyset-пагинацией. Basic-вход,
Bearer-сессии в Redis с TTL и AOF-персистентностью. make check/test/
test-persistence/validate зелёные; evidence по EXPLAIN ANALYZE, короткому
TTL и падению Redis приложены в REPORT.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 00:23:26 +03:00
co-authored by Claude Sonnet 5
parent 65003b6119
commit d12159a8cc
13 changed files with 886 additions and 15 deletions
+34
View File
@@ -0,0 +1,34 @@
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=112.38..112.51 rows=51 width=88) (actual time=4.990..4.998 rows=51 loops=1)
Buffers: shared hit=271
-> Sort (cost=112.38..112.51 rows=52 width=88) (actual time=4.986..4.989 rows=51 loops=1)
Sort Key: created_at, id
Sort Method: top-N heapsort Memory: 36kB
Buffers: shared hit=271
-> Bitmap Heap Scan on messages (cost=4.69..110.90 rows=52 width=88) (actual time=1.292..2.987 rows=12000 loops=1)
Recheck Cond: (chat_id = 'c939f183-65af-4ab7-b565-cd5328e24289'::uuid)
Heap Blocks: exact=148
Buffers: shared hit=265
-> Bitmap Index Scan on messages_chat_keyset_idx (cost=0.00..4.67 rows=52 width=0) (actual time=1.247..1.248 rows=12000 loops=1)
Index Cond: (chat_id = 'c939f183-65af-4ab7-b565-cd5328e24289'::uuid)
Buffers: shared hit=117
Planning:
Buffers: shared hit=102
Planning Time: 0.488 ms
Execution Time: 5.050 ms
(17 rows)
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.29..4.65 rows=51 width=65) (actual time=0.040..0.267 rows=51 loops=1)
Buffers: shared hit=53
-> Index Scan using messages_chat_keyset_idx on messages (cost=0.29..1026.72 rows=12000 width=65) (actual time=0.039..0.258 rows=51 loops=1)
Index Cond: (chat_id = 'c939f183-65af-4ab7-b565-cd5328e24289'::uuid)
Buffers: shared hit=53
Planning:
Buffers: shared hit=107
Planning Time: 0.661 ms
Execution Time: 0.309 ms
(9 rows)