Class CacheUtils
java.lang.Object
com.arbergashi.charts.util.CacheUtils
Utility for bounded LRU caches.
This prevents memory leaks caused by unbounded caches in long-running applications.
- Since:
- 2026-01-01
- Version:
- 1.0.0
- Author:
- Arber Gashi
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> Map <K, V> newBoundedMap(int maxEntries) Creates a bounded LRU cache with a fixed maximum size.
-
Method Details
-
newBoundedMap
Creates a bounded LRU cache with a fixed maximum size.Uses
LinkedHashMapfor automatic eviction of the eldest entry.- Type Parameters:
K- key typeV- value type- Parameters:
maxEntries- maximum number of entries (e.g. 64 for gradient caches)- Returns:
- a map instance with LRU behavior
-