You are working on the hyperswitch repository (Rust payment processing system).…
- User
You are working on the hyperswitch repository (Rust payment processing system).
REPOSITORY SETUP:
- Repository: juspay/hyperswitch
- Working directory: ./repos/hyperswitch_pool_8 (already cloned)
- Base commit: 776bde00efce8be35e0c63c1bdc6215921babddf
- Task ID: juspay__hyperswitch-7870
- Version: v1.113.0
TASK DESCRIPTION: Bug: Add support for caching and resolving last used lineage context
Currently, after a user logs in and switches between merchants or profiles, their context is not remembered across sessions.
Each new login resolves the default role from the DB and starts with a clean slate.This leads to:
- Poor user experience for users with multiple roles
- Repetitive DB queries for every login
- No continuity across logins for previously active merchant/profile context
Objective
Introduce a mechanism to cache the last used lineage context (
org_id,merchant_id,profile_id,role_id,tenant_id) in Redis and use it for JWT generation on subsequent logins.Expected Behavior
- During login:
- If lineage context exists in Redis → use it to validate and generate the JWT.
- If not found or invalid → fallback to default DB-based user role resolution.
- During merchant/profile switch:
- Store the latest lineage context in Redis for future use.
- Redis entries should have a TTL of 7 days to auto-expire for inactive users.
DETAILED CONTEXT & HINTS:
Type of Change
- Bugfix
- New feature
- Enhancement
- Refactoring
- Dependency updates
- Documentation
- CI/CD
Description
This PR introduces lineage context caching to enhance login and account-switch flows with better continuity and reduced DB load.
Key Changes
Assistant
I'll implement the lineage context caching feature for the Hyperswitch repository. Let me start by understanding the codebase structure and identifying the relevant files for login and context management.
First, I'll explore the repository structure to locate authentication and context-related code:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.