Skip to content

Conversation

@simzzz
Copy link
Contributor

@simzzz simzzz commented Oct 30, 2025

Description

CacheService stores Redis keys without a prefix, while other services use prefixes (pending:*, hbar-limit:*, etc.). This causes:

  1. Unsafe clearing: CacheService.clear() can't distinguish its keys from others, so we hardcode a filter:

    const keysToDelete = allKeys.filter((key) => !key.startsWith('pending:'));

    This couples RedisCache to TransactionPoolService and doesn't scale.

  2. No ownership: Can't tell which keys belong to which service.

  3. Maintenance burden: Every new Redis user must update the filter.

This PR solves that by adding the prefix to all CacheService keys. The pending: key was also changed to txpool:pending. All tests have been added to reflect that.

Related issue(s)

Fixes #4501

Testing Guide

  1. Call any method using cache
  2. Check keys in Redis

Changes from original design (optional)

N/A

Additional work needed (optional)

N/A

Checklist

  • I've assigned an assignee to this PR and related issue(s) (if applicable)
  • I've assigned a label to this PR and related issue(s) (if applicable)
  • I've assigned a milestone to this PR and related issue(s) (if applicable)
  • I've updated documentation (code comments, README, etc. if applicable)
  • I've done sufficient testing (unit, integration, etc.)

Signed-off-by: Simeon Nakov <[email protected]>
@simzzz simzzz added this to the 0.74.0 milestone Oct 30, 2025
@simzzz simzzz self-assigned this Oct 30, 2025
@simzzz simzzz added the enhancement New feature or request label Oct 30, 2025
@github-actions
Copy link

github-actions bot commented Oct 30, 2025

Test Results

 20 files  ±0  269 suites  ±0   21m 51s ⏱️ -19s
778 tests ±0  774 ✅ +1  4 💤 ±0  0 ❌  - 1 
794 runs  ±0  790 ✅ +1  4 💤 ±0  0 ❌  - 1 

Results for commit c201a06. ± Comparison against base commit 65c2bb1.

♻️ This comment has been updated with latest results.

@simzzz simzzz marked this pull request as ready for review October 30, 2025 13:16
@simzzz simzzz requested review from a team as code owners October 30, 2025 13:16
@simzzz simzzz requested a review from quiet-node October 30, 2025 13:16
Copy link
Contributor

@quiet-node quiet-node left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@simzzz simzzz requested review from a team and acuarica November 3, 2025 08:55
@simzzz simzzz merged commit fc9d456 into main Nov 4, 2025
143 of 153 checks passed
@simzzz simzzz deleted the 4501-add-prefix-to-redis-cache-class branch November 4, 2025 09:20
@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

❌ Patch coverage is 98.75000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/relay/src/lib/clients/cache/redisCache.ts 97.82% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #4559      +/-   ##
==========================================
+ Coverage   95.01%   95.53%   +0.51%     
==========================================
  Files         127      127              
  Lines       20447    20496      +49     
  Branches     1734     1759      +25     
==========================================
+ Hits        19427    19580     +153     
+ Misses       1000      897     -103     
+ Partials       20       19       -1     
Flag Coverage Δ
config-service 98.81% <ø> (ø)
relay 90.95% <98.75%> (+0.02%) ⬆️
server 88.85% <ø> (ø)
ws-server 98.04% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...kages/relay/src/lib/clients/cache/localLRUCache.ts 93.70% <100.00%> (+0.47%) ⬆️
...ctionPoolService/RedisPendingTransactionStorage.ts 100.00% <100.00%> (ø)
packages/relay/src/lib/clients/cache/redisCache.ts 94.13% <97.82%> (+0.60%) ⬆️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add cache: prefix to Redis Cache class

4 participants