forked from mtusi2026/mtusi2026lab3
16 lines
702 B
SQL
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);
|