Class QueryExecutionCache
java.lang.Object
com.loomcache.server.query.QueryExecutionCache
Caches query results for identical queries within a TTL window.
Invalidates entries when underlying maps are modified.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordStatistics about cache performance. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a QueryExecutionCache with default settings (5000ms TTL, 500 entries).QueryExecutionCache(long ttlMs, int maxCacheSize) Creates a new QueryExecutionCache with configurable TTL and max size. -
Method Summary
Modifier and TypeMethodDescriptionvoidCaches a query result.voidclear()Clears all cached results.getIfPresent(String sql) Returns a cached result if available and not expired, or null.getStats()Returns cache performance statistics.voidinvalidateForMap(String mapName) Invalidates cache entries for a specific map name.
-
Constructor Details
-
QueryExecutionCache
public QueryExecutionCache(long ttlMs, int maxCacheSize) Creates a new QueryExecutionCache with configurable TTL and max size.- Parameters:
ttlMs- time-to-live in milliseconds (default 5000)maxCacheSize- maximum entries to cache (default 500)
-
QueryExecutionCache
public QueryExecutionCache()Creates a QueryExecutionCache with default settings (5000ms TTL, 500 entries).
-
-
Method Details
-
getIfPresent
-
cache
-
invalidateForMap
Invalidates cache entries for a specific map name.- Parameters:
mapName- the map that was modified
-
clear
public void clear()Clears all cached results. -
getStats
Returns cache performance statistics.- Returns:
- CacheStats with hit rate and size
-