Files
mtusi2026lab7/migrations/003_cache_invalidations.sql
T
ejur22 d995f98446
Skeleton contracts / contracts (pull_request) Canceled after 0s
Lab 7
2026-11-27 20:47:58 +03:00

16 lines
702 B
SQL

-- Lab3 durable cache invalidation queue.
--
-- Logout deletes the authoritative session row in PostgreSQL and enqueues the
-- token hash here in the SAME transaction. A lightweight background drainer in
-- each API replica removes the corresponding Valkey cache key and then the row.
-- If Valkey was unreachable at logout time, the row survives and the stale
-- cache entry is removed as soon as the cache comes back, instead of being
-- trusted until its TTL.
create table if not exists cache_invalidations (
token_hash text primary key,
created_at timestamptz not null default now()
);
create index if not exists cache_invalidations_created_at_idx
on cache_invalidations (created_at);