hyperswitch icon indicating copy to clipboard operation
hyperswitch copied to clipboard

Persist Last Used Lineage Context in Database Instead of Redis

Open tsdk02 opened this issue 7 months ago • 0 comments

Currently, the last used lineage context (org_id, merchant_id, profile_id, role_id, tenant_id) is cached temporarily in Redis with a 7-day TTL. While this improves user experience across sessions, it introduces problems like:

  • Redis is volatile — lineage context is lost if redis crashes
  • Users switching between v1/v2 deployments have inconsistent Redis prefixes, leading to stale context (this has been fixed)
  • Adds unnecessary dependency on Redis for critical authentication flow.

Objectives:

  • Move the lineage context storage from Redis to the database (preferably to the users table as a new column).
  • Ensure lineage context is persistently stored and updated in DB.

Tasks:

  • [ ] Add a new nullable last_used_lineage_context (JSON/JSONB) column to the users table.

  • [ ] Modify lineage context get and set helpers to use the DB instead of Redis.

tsdk02 avatar Apr 29 '25 11:04 tsdk02