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.
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.