Skip to content

feat: Add response caching for safe read operations#636

Merged
Cedarich merged 4 commits into
Pulsefy:mainfrom
drips-projects:Add-Response-Caching
Jun 25, 2026
Merged

feat: Add response caching for safe read operations#636
Cedarich merged 4 commits into
Pulsefy:mainfrom
drips-projects:Add-Response-Caching

Conversation

@Joeloo1

@Joeloo1 Joeloo1 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Description

Implements Redis-based response caching to reduce repeated compute for safe read operations.

Changes

Backend (NestJS)

  • Added decorator and
  • Cached 8 GET endpoints (verification, aid-escrow, transactions)
  • Configurable TTL per endpoint type (30s to 30min)
  • Automatic testnet TTL adjustments
  • Cache key normalization using SHA-256 hash
  • for pattern-based invalidation

AI Service (Python)

  • Added with decorator
  • Cached task status polling endpoints (30s TTL)
  • Automatic serialization/deserialization
  • Graceful degradation if Redis unavailable

Features

  • ✅ Cache key includes normalized inputs (SHA-256 hash)
  • ✅ TTL is configurable via environment variables
  • ✅ Safe for testnet (read-only, longer TTLs, graceful degradation)
  • Fail-open design (cache errors don't block requests)
  • Comprehensive unit tests for both services
  • Helper services for cache invalidation
  • Full documentation (CACHING.md, IMPLEMENTATION_GUIDE.md)

Testing

  • Unit tests added for both backend and AI service
  • Manual testing verified cache hit/miss behavior
  • Redis integration tested

Documentation

  • Added CACHING.md with comprehensive documentation
  • Added IMPLEMENTATION_GUIDE.md for quick reference
  • Updated .env.example files with new configuration

Closes #619

Implements Redis-based response caching to reduce repeated compute for safe read endpoints.

- Backend: 8 cached GET endpoints with configurable TTL (30s-30min)
- AI Service: Task status caching with 30s TTL
- Cache key normalization using SHA-256 hash
- Testnet-safe with automatic TTL adjustments
- Graceful degradation if Redis unavailable

Closes Pulsefy#619
@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

@Joeloo1 is attempting to deploy a commit to the Cedarich's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jun 24, 2026

Copy link
Copy Markdown

@Joeloo1 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

@Cedarich

Copy link
Copy Markdown
Contributor

@Joeloo1 fix qorkflow

Joeloo1 added 2 commits June 25, 2026 16:39
- Fix async promise handling in cache interceptor
- Remove unused CACHE_RESPONSE_KEY import
- Remove async from getCacheStats (no await needed)
- Fix Python test mocking to patch main.app instead of services.cache.app
- Add error handler to TypeScript test to prevent timeout
- Simplify Python test mocking to avoid import issues
- Mock main.app directly instead of patching module imports
@Cedarich

Copy link
Copy Markdown
Contributor

@Joeloo1

- Add error handler to prevent test timeout
- Mock redisService.set to ensure promise chain completes
- Use subscribe object notation for proper error handling
@Cedarich Cedarich merged commit a2e9b29 into Pulsefy:main Jun 25, 2026
8 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

Development

Successfully merging this pull request may close these issues.

Add Response Caching for Idempotent Reads (Safe TTL)

2 participants