Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cycle record data cache #14

Merged
merged 1 commit into from
May 8, 2024
Merged

Add cycle record data cache #14

merged 1 commit into from
May 8, 2024

Conversation

tanuj-shardeum
Copy link
Contributor

The /cycleinfo/ GET endpoint returns a list of the latest count cycleRecords. Every call to the /cycleinfo/ endpoint makes a query to the database, resulting in high latency. This PR intends to introduce a cache to store a configurable number of cycle records, controlled by the REQUEST_LIMIT.MAX_CYCLES_PER_REQUEST config variable. The cache is maintained using a Queue data structure. Initially, a query is made to the database to populate the cache with existing cycleRecords. Then, further cycle records are added via the processCycle() function, which adds the latest cycle record to the cache. If the cache exceeds the maximum allowed size, the oldest cycle record is popped from the cache.

Copy link

linear bot commented May 1, 2024

BLUE-57 Cache the latest 100 cycles in the archiver

ISSUE SUMMARY:

The cycleinfo/<count> endpoint is open to all, everytime it gets called, the archiver queries from the archiver-db.

Instead, we should have a cache where we keep the latest 100 cycles. As new cycles are received, it should remove older entries to maintain a limit of 100 cycles in the cache.

Also, the cycleinfo/<count> endpoint should respond the cycles in descending order in terms of cycleNumber.


ISSUE REPRO STEPS:

<HINT: Add steps to list as-needed. If interaction is complex, add screenshots or a Slack screen-capture video (just drag and drop)>

  1. <<TODO: Replace with repro step Bump the npm_and_yarn group across 1 directory with 3 updates #1>>
  2. <<TODO: Replace with repro step Challenge receipt #2>>
  3. Observe <<TODO: Describe unintended behavior.>>

EXPECTED RESULT:

<<TODO: Replace this with your expected results.>>


MERGE REQUESTS:

<HINT: If your fix requires changes in multiple repos, add the following info per-repository.>

<<TODO: Enter Repository Name>>

Pull Request Link: <<TODO: Insert PR-LINK>>

GPT Review Link: <<TODO: Insert GPT-Review-Link>>

Jenkins Test Link: <<TODO: Insert Jenkins Test Job Link>>


ADDITIONAL INSTRUCTIONS:

<HINT: Add any additional instructions needed for the assignee. If you have specific requirements for how the task should be implemented or fixed, enter them or link them here.>

<<TODO: Insert additional instructions for assignee.>>

@jairajdev jairajdev merged commit b1ce45b into dev May 8, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants