Skip to content

feat: add adaptive cache invalidation hooks for transaction state#875

Merged
Junirezz merged 4 commits into
Junirezz:mainfrom
dinahmaccodes:issue-mix
Jun 29, 2026
Merged

feat: add adaptive cache invalidation hooks for transaction state#875
Junirezz merged 4 commits into
Junirezz:mainfrom
dinahmaccodes:issue-mix

Conversation

@dinahmaccodes

@dinahmaccodes dinahmaccodes commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

PR Description

Backend: Adaptive Cache Invalidation Hooks (#637)

Implemented a hook-based system for triggering targeted cache invalidation when writes change dependent read models. The system allows registering invalidation hooks that return cache key patterns to clear based on transaction events.

Changes:

  • Added registerInvalidationHook() and triggerCacheInvalidation() to cache middleware
  • Registered hooks for transaction state changes (deposits/withdrawals)
  • Updated vault endpoints to trigger invalidation via hooks instead of manual calls
  • Maintains backwards compatibility with existing cache behavior

Backend: Redis-Backed Adaptive Throttle (#862)

Enhanced the adaptive throttle middleware to use Redis for distributed state when REDIS_URL is configured, enabling throttling to work across multiple backend instances.

Changes:

  • Created RedisAbuseStore class that falls back to in-memory storage when Redis is unavailable
  • Added async/await pattern for Redis operations with error handling
  • Integrated with existing redisClientManager from rate limiter
  • Added throttle metrics: adaptive_throttle_block_count and adaptive_throttle_active_blocks
  • Maintains in-memory fallback for local/test environments with startup warning

Backend: Retry Budget Limits for RPC Dependencies (#630)

Introduced configurable retry budget controls to prevent runaway retries under upstream Soroban RPC failures.

Changes:

  • Created RetryBudgetService with configurable limits (max retries, window, success rate, failure threshold)
  • Integrated retry budget into sorobanClient.ts with exponential backoff
  • Added retryWithBudget() helper that respects budget limits
  • Environment variables: RETRY_BUDGET_MAX_RETRIES, RETRY_BUDGET_WINDOW_MS, RETRY_BUDGET_MIN_SUCCESS_RATE, RETRY_BUDGET_FAILURE_THRESHOLD
  • Automatic success/failure tracking and budget enforcement

Frontend: Cross-Page Toast Center with Deduplication (#619)

Enhanced the toast notification system with deduplication to prevent showing identical toasts multiple times.

Changes:

  • Added dedupeKey option to ToastOptions for custom deduplication
  • Automatic deduplication based on title+description+variant within 3-second window
  • Added clearAll() method to dismiss all toasts
  • Periodic cleanup of stale deduplication entries
  • Maintains consistent severity styles across pages

Checklist

  • Adaptive cache invalidation hooks implemented
  • Redis-backed adaptive throttle state added
  • Retry budget limits for RPC dependencies implemented
  • Cross-page toast center with deduplication added
  • Backwards compatibility maintained for all changes
  • Proper error handling and fallbacks implemented
  • Environment variable configuration added where appropriate

Closes #637
Closes #862
Closes #630
Closes #619

@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

@dinahmaccodes Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@dinahmaccodes

Copy link
Copy Markdown
Contributor Author

@Junirezz
please review maintainer

@Junirezz Junirezz merged commit f5a67b4 into Junirezz:main Jun 29, 2026
6 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants