Skip to content

Perf/redis auth cache#46

Merged
ademboukabes merged 1 commit into
mainfrom
perf/redis-auth-cache
May 30, 2026
Merged

Perf/redis auth cache#46
ademboukabes merged 1 commit into
mainfrom
perf/redis-auth-cache

Conversation

@ademboukabes
Copy link
Copy Markdown
Collaborator

Cache mobile sessions in Redis to reduce database load

Description

Optimizes mobile user authentication by caching active sessions in Redis, avoiding PostgreSQL queries on every authenticated request.

Changes

  • Created MobileSessionCache schema in the session service.
  • Updated get_current_mobile_user dependency to retrieve session info from Redis first, falling back to PostgreSQL only on cache miss.
  • Updated login, verification, and block/delete user flows to handle cache initialization and invalidation.

Replace 2 Postgres queries per request with a Redis cache lookup.
Cache key: session:{session_id} → MobileSessionCache JSON.
Graceful fallback to Postgres when cache miss. Cache is populated
on login and invalidated on user block/delete.
@ademboukabes ademboukabes force-pushed the perf/redis-auth-cache branch from bf3e1b3 to 933671d Compare May 30, 2026 13:56
@ademboukabes ademboukabes merged commit cfb56a5 into main May 30, 2026
1 check passed
@ademboukabes ademboukabes deleted the perf/redis-auth-cache branch May 30, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant