feat(lib): cache blockhash in redis (5s TTL)#361
Merged
dev-jodee merged 3 commits intosolana-foundation:release/2.2.0from Mar 3, 2026
Merged
feat(lib): cache blockhash in redis (5s TTL)#361dev-jodee merged 3 commits intosolana-foundation:release/2.2.0from
dev-jodee merged 3 commits intosolana-foundation:release/2.2.0from
Conversation
Contributor
Greptile SummaryAdds Redis caching for Key Changes:
Notes:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant GetBlockhash as get_blockhash endpoint
participant CacheUtil
participant Redis
participant RPC as Solana RPC
Client->>GetBlockhash: Request blockhash
GetBlockhash->>CacheUtil: get_or_fetch_latest_blockhash()
alt Cache enabled
CacheUtil->>Redis: GET kora:blockhash
alt Cache hit
Redis-->>CacheUtil: Return cached hash
CacheUtil-->>GetBlockhash: Return hash
else Cache miss
Redis-->>CacheUtil: None
CacheUtil->>RPC: get_latest_blockhash_with_commitment(confirmed)
RPC-->>CacheUtil: Fresh blockhash
CacheUtil->>Redis: SET kora:blockhash (TTL: 5s)
CacheUtil-->>GetBlockhash: Return hash
end
else Cache disabled/error
CacheUtil->>RPC: get_latest_blockhash_with_commitment(confirmed)
RPC-->>CacheUtil: Fresh blockhash
CacheUtil-->>GetBlockhash: Return hash
end
GetBlockhash-->>Client: Return blockhash
Last reviewed commit: f0e8939 |
f0e8939 to
c8509a1
Compare
Contributor
|
@raushan728 if you can fix the ci issue, rest looks good |
Contributor
Author
|
hi @dev-jodee is current soluntion is good or should i use |
Contributor
|
@raushan728 the fix is to get a reference of get_config like so
|
b511f59 to
bd04aad
Compare
Contributor
Author
|
@dev-jodee done |
dev-jodee
approved these changes
Mar 3, 2026
|
✅ Fork external live tests passed. fork-external-live-pass:bd04aad5bed631fa1d127eb6dbd93e64bcc2aa70 |
f8d27f8
into
solana-foundation:release/2.2.0
11 of 12 checks passed
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.
Adds a 5-second Redis cache for
getLatestBlockhashto reduce RPC load on high-traffic endpoints.get_blockhashandtransfer_transactionnow use cached blockhash.