Forward the lab 4 foundation and migrate the lab 5 pipeline to SQLAlchemy

This commit is contained in:
Artyom
2026-11-06 09:12:25 +03:00
parent ae9f60fe1f
commit 1217da5f5e
134 changed files with 8243 additions and 1409 deletions
+19 -8
View File
@@ -11,14 +11,25 @@ cli "info persistence" | grep -E '^aof_enabled|^aof_last_write_status'
echo "\$ valkey-cli dbsize; info stats | grep keyspace"
cli dbsize
cli "info stats" | grep -E '^keyspace_(hits|misses)'
key=$(cli "--scan --pattern session:* --count 1000" | head -1)
hash=${key#session:}
echo "\$ сравнение срока ключа кэша и срока сессии для одного ключа (значение и токен не печатаются)"
echo "valkey pexpiretime, ms: $(cli "pexpiretime $key")"
echo "postgres expires_at, ms: $(psql "SELECT (extract(epoch FROM expires_at) * 1000)::bigint FROM sessions WHERE token_hash = decode('$hash', 'hex')")"
echo "\$ количество отметок отзыва и закэшированных сессий"
revoked=0; cached=0
echo "\$ valkey-cli --scan --pattern 'session:*' и вид значения (хеш сокращён, значения не печатаются)"
revoked=0; cached=0; key=""; stored=""
for k in $(cli "--scan --pattern session:* --count 1000"); do
if [ "$(cli "get $k")" = "-" ]; then revoked=$((revoked + 1)); else cached=$((cached + 1)); fi
if [ "$(cli "get $k")" = "-" ]; then
revoked=$((revoked + 1)); printf '%.16s… отметка отзыва "-"\n' "$k"; continue
fi
cached=$((cached + 1)); printf '%.16s… сессия\n' "$k"
if [ -z "$key" ]; then
stored=$(psql "SELECT (extract(epoch FROM expires_at) * 1000)::bigint FROM sessions WHERE token_hash = decode('${k#session:}', 'hex')")
if [ -n "$stored" ]; then key=$k; fi
fi
done
echo "tombstones: $revoked, cached sessions: $cached"
if [ "$revoked" -eq 0 ] || [ -z "$key" ]; then
echo "нужны закэшированная сессия из БД и отметка отзыва: сначала make test" >&2
exit 1
fi
expires=$(cli "pexpiretime $key")
echo "\$ срок ключа кэша против срока сессии для $(printf '%.16s' "$key")…"
echo "valkey pexpiretime, ms: $expires"
echo "postgres expires_at, ms: $stored"
if [ "$expires" -le "$stored" ]; then echo "ключ не переживает сессию: да"; else echo "ключ не переживает сессию: НЕТ"; exit 1; fi