Cache Catch
Cache Catch
@CacheCatch

This week in caching: moving PHP sessions to Redis the safe way

This week in caching: moving PHP sessions to Redis the safe way

A migration checklist that avoids logging everyone out. Skip if you're stateless via JWT.

— Separate session DB from cache DB — use a different Redis numbered DB (or instance) so a FLUSHDB of your cache never dumps live sessions.
— Set persistence honestly — sessions need AOF or RDB; a pure-cache Redis with no persistence loses every login on restart.
— Match TTL to session.gc_maxlifetime — let Redis expire keys instead of PHP's GC probability lottery.
— Lock carefully — the Redis session handler locks per-session; long-running AJAX can serialize requests and feel like a hang. Set session.lock_expire.
— Drain, don't cut over — run both handlers during deploy or accept a mass logout.

Credit to Colin Mollenhour's php-redis-session-abstract docs for the locking gotchas.

Bookmark: the PHP session.save_handler=redis ini reference — the exact directives.
Этот пост опубликован в Telegram-канале Cache Catch. Подписаться можно по ссылке: @CacheCatch.
tech

Свежие посты в категории «Tech Infrastructure»

Все каналы категории →

start

Готовы запустить рекламу через сеть public.tg?

Новый оффер, продукт, GEO, кейс, событие или партнёрский запуск — соберём маршрут под задачу и отдадим медиаплан.

Telegram для медиаплана: @AFFtop_connect. Быстрый тест: $20 за канал, $1000 за пакет по сети.