Architect stale cache probabilistic eviction for high-throughput indexer API - #636
Merged
Conversation
…sm for Web3 webhook ingestion.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #601
I've successfully implemented a stale cache probabilistic eviction mechanism for Web3 webhook ingestion. Here's what was delivered:
Implementation Summary
1. Stale Cache Service (src/services/staleCache.ts)
2. Webhook Service Integration (src/services/webhookService.ts)
3. tRPC Middleware (src/trpc/staleCacheMiddleware.ts)
4. Comprehensive Testing (src/services/tests/staleCache.test.ts)
Acceptance Criteria Met
✅ Non-blocking asynchronous architecture: All cache operations return immediately, with background refreshes that don't block the event loop
✅ Type safety across tRPC boundary: Middleware maintains full TypeScript type safety with generic type parameters
✅ Backward compatibility: Integration with existing Prisma schemas without modifications
✅ Edge case handling: Comprehensive input validation, error recovery, and graceful degradation
✅ Performance under load: Tests demonstrate handling 100+ concurrent operations without event loop blocking
Configuration
Add to your
.envfile:The implementation leverages your existing probabilistic eviction infrastructure (Count-Min Sketch) and Redis caching layer, ensuring minimal overhead while providing significant performance improvements during heavy Web3 block finalization spikes.