Skip to content

fix(api): cap API client response cache with LRU eviction (#1161) - #1310

Merged
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
Killerjunior:fix/1161-cap-api-client-response-cache-lru
Aug 31, 2026
Merged

fix(api): cap API client response cache with LRU eviction (#1161)#1310
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
Killerjunior:fix/1161-cap-api-client-response-cache-lru

Conversation

@Killerjunior

Copy link
Copy Markdown
Contributor

Description

Implemented an LRU (Least Recently Used) eviction policy and configurable capacity cap for the in-memory API client response cache to prevent unbounded memory growth:

  • Added API_CACHE_MAX_ENTRIES_DEFAULT and API_CACHE_MAX_SIZE_DEFAULT constants to app.constants.ts.
  • Updated api.ts to support configurable maxCacheSize and maxCacheEntries in ApiClientConfig.
  • Implemented LRU cache access and eviction logic (getFromCache / setInCache) that updates recency on reads/writes and evicts oldest entries when capacity is exceeded.
  • Added comprehensive unit tests in api.test.ts covering caching behavior, LRU eviction order, MRU promotion on cache hit, configurable limits, and cache invalidation.

Related Issue

Closes #1161

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • No console errors
  • Uses Lucide icons consistently
  • Responsive design implemented
  • Starknet best practices followed

@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@Killerjunior Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project

@RUKAYAT-CODER
RUKAYAT-CODER merged commit def7cb5 into rinafcode:main Aug 31, 2026
6 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.

Cap API client response cache with LRU eviction

2 participants