Skip to content

perf(cache): Implement a layered Redis caching strategy for high-frequency contract translations #113

Description

@grantfox-oss

Area: Performance & Caching

Difficulty: Medium

Labels: Type: Performance, Layer: Core-Translation

Context & Problem Statement
On-chain events are completely immutable; once an event is emitted and decoded on a specific ledger, its plain-English translation will never change. Currently, our system re-runs the translation string interpolation logic and template assembly every time a user requests an event log via the API. For high-volume contracts (like AMM liquidity pools), this causes redundant CPU cycles and unnecessary database reads.

Proposed Implementation Plan
Introduce a Redis instance into the infrastructure and configure a layered caching pipeline.

For read requests, implement a Cache-Aside pattern: use a deterministic cache key combined from the event's unique blockchain signature (tx_hash + event_index).

If a cache hit occurs, bypass database serialization and return the pre-compiled translation payload directly.

Set an intelligent eviction policy, or keep historical event translations permanently cached while applying a standard Time-To-Live (TTL) exclusively to volatile dashboard aggregation metrics.

Acceptance Criteria
[ ] Read operations for highly requested event logs show a >60% reduction in response latency under heavy load simulations.

[ ] Cache invalidation scripts successfully purge old schema formats if an emergency correction is pushed to the Translation Registry.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions