feat(backend): cache listServices to reduce RPC simulation calls#195
feat(backend): cache listServices to reduce RPC simulation calls#195leocagli wants to merge 1 commit into
Conversation
…calls Closes Stellar-Ecosystem#6 Every paginated request to GET /api/services was invoking a full Soroban simulation call to list_services_page — expensive with many concurrent users or rapid polling. Changes: - Added per-key in-memory cache in contract.js keyed on category:page:pageSize - Cache TTL = 30s (matches the frontend's SWR refreshInterval) - Cache is invalidated on registerServiceOnChain() so newly-registered services appear on the next request without waiting for TTL expiry - Exported invalidateServicesCache() for routes that mutate service state
|
Warning Review limit reached
More reviews will be available in 1 second. Learn how PR review limits work. To continue reviewing without waiting, enable usage-based billing in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Closes #6
Summary
Every call to
GET /api/servicestriggered a Soroban simulation call tolist_services_page— one per page, per request. With concurrent users or the frontend's 30s auto-refresh, this creates unnecessary load on the RPC node.contract.jskeyed oncategory:page:pageSizerefreshInterval)invalidateServicesCache()is called automatically insideregisterServiceOnChain()so newly-registered services appear immediately without waiting for TTL expiryTest plan
registerServiceOnChain(), the nextGET /api/servicesshows the new service (cache was invalidated)