Skip to content

refactor(core): add cache redaction for cgraph#9629

Merged
likhinbopanna merged 9 commits intomainfrom
refactor_cgraph_cache
Oct 1, 2025
Merged

refactor(core): add cache redaction for cgraph#9629
likhinbopanna merged 9 commits intomainfrom
refactor_cgraph_cache

Conversation

@prajjwalkumar17
Copy link
Member

@prajjwalkumar17 prajjwalkumar17 commented Sep 30, 2025

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

This pull request enhances cache management for connector creation by introducing a new mechanism to invalidate related cache entries whenever a new connector is added. The main change is the addition of the redact_cgraph_cache function, which ensures that outdated cgraph cache data is cleared for the relevant merchant and profile, preventing stale data issues.

Cache invalidation improvements:

  • Added the redact_cgraph_cache function in crates/router/src/core/routing/helpers.rs to invalidate both payouts and payments cgraph cache entries for a given merchant and profile. This function uses Redis and publishes cache invalidation events.
  • Integrated the redact_cgraph_cache call into the connector creation flow in crates/router/src/core/admin.rs, ensuring cache is redacted whenever a new connector is created.
  • Imported the redact_cgraph_cache helper function in crates/router/src/core/admin.rs to enable its usage in the admin logic.

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

Required for cache redaction.

How did you test it?

  1. Create wise connector with sepa enabled.
  2. Create/confirm a sepa payout link.
curl --location 'http://localhost:8080/payouts/create' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_7ac45zCz3UdpgVnwr0KrU5eT7kFYgIvuR6rtHT2gwj9zRqMZDvI5XMFXhWu7RX85' \
--data-raw '{
    "amount": 4500,
    "currency": "USD",
    "customer_id": "cus_jtJ8WHTHnsguskpiorEt",
    "email": "payout_customer@example.com",
    "name": "Doest John",
    "phone": "6168205366",
    "phone_country_code": "+1",
    "description": "Its my first payout request",
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "NY",
            "zip": "94122",
            "country": "US",
            "first_name": "John",
            "last_name": "Doe"
        },
        "phone": {
            "number": "6168205366",
            "country_code": "1"
        }
    },
    "entity_type": "Individual",
    "recurring": false,
    "metadata": {
        "ref": "123"
    },
    "confirm": false,
    "auto_fulfill": false,
    "payout_link": true,
    "payout_link_config": {
        "logo": "https://hyperswitch.io/favicon.ico",
        "merchant_name": "Hyperswitch",
        "theme": "#4285F4",
        
        "test_mode": true,
        "form_layout": "tabs"
    }
}'
  1. create adyen mca with card.
  2. Create/confirm a card payout link(it should be processed with adyen and not wise).
curl --location 'http://localhost:8080/payouts/create' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_7ac45zCz3UdpgVnwr0KrU5eT7kFYgIvuR6rtHT2gwj9zRqMZDvI5XMFXhWu7RX85' \
--data-raw '{
    "amount": 4500,
    "currency": "USD",
    "customer_id": "cus_jtJ8WHTHnsguskpiorEt",
    "email": "payout_customer@example.com",
    "name": "Doest John",
    "phone": "6168205366",
    "phone_country_code": "+1",
    "description": "Its my first payout request",
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "NY",
            "zip": "94122",
            "country": "US",
            "first_name": "John",
            "last_name": "Doe"
        },
        "phone": {
            "number": "6168205366",
            "country_code": "1"
        }
    },
    "entity_type": "Individual",
    "recurring": false,
    "metadata": {
        "ref": "123"
    },
    "confirm": false,
    "auto_fulfill": false,
    "payout_link": true,
    "payout_link_config": {
        "logo": "https://hyperswitch.io/favicon.ico",
        "merchant_name": "Hyperswitch",
        "theme": "#4285F4",
        
        "test_mode": true,
        "form_layout": "tabs"
    }
}'

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@prajjwalkumar17 prajjwalkumar17 self-assigned this Sep 30, 2025
@prajjwalkumar17 prajjwalkumar17 requested review from a team as code owners September 30, 2025 12:44
@prajjwalkumar17 prajjwalkumar17 added the A-routing Area: Routing label Sep 30, 2025
@semanticdiff-com
Copy link

semanticdiff-com bot commented Sep 30, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/admin.rs  0% smaller
  crates/router/src/core/routing/helpers.rs  0% smaller
  crates/router/src/core/subscription.rs  0% smaller

@prajjwalkumar17 prajjwalkumar17 marked this pull request as draft September 30, 2025 12:47
@Sarthak1799
Copy link
Contributor

Please add redact to update mca as well

@prajjwalkumar17 prajjwalkumar17 marked this pull request as ready for review September 30, 2025 14:32
@Sarthak1799
Copy link
Contributor

CI checks are failing @prajjwalkumar17

@likhinbopanna likhinbopanna added this pull request to the merge queue Oct 1, 2025
Merged via the queue into main with commit 654ffe4 Oct 1, 2025
21 of 25 checks passed
@likhinbopanna likhinbopanna deleted the refactor_cgraph_cache branch October 1, 2025 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-routing Area: Routing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor(core): redact cache for cgraph on new connector create

4 participants