SearchResultsCache<T> class
Cache for storing search results with LRU eviction policy
Features:
- Automatic expiration of old entries
- LRU (Least Recently Used) eviction policy
- Hit/miss tracking for performance monitoring
- Prefix matching for better cache utilization
- Memory-efficient storage
Constructors
- SearchResultsCache({int maxSize = 100, Duration maxAge = const Duration(minutes: 30), bool enablePrefixMatching = true})
Properties
- enablePrefixMatching → bool
-
final
- evictions → int
-
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hitRate → double
-
Get cache hit rate (0.0 to 1.0)
no setter
- hits → int
-
no setter
- maxAge → Duration
-
final
- maxSize → int
-
final
- misses → int
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → int
-
no setter
Methods
-
cleanExpired(
) → void - Remove expired entries
-
clear(
) → void - Clear all cache
-
contains(
String query) → bool - Check if query is in cache and valid
-
get(
String query) → List< T> ? - Get cached results for a query
-
getStats(
) → CacheStats - Get cache statistics
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
remove(
String query) → void - Remove a specific entry from cache
-
resetMetrics(
) → void - Reset cache metrics
-
set(
String query, List< T> results) → void - Store results in cache
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited