set method

void set(
  1. String query,
  2. List<T> results
)

Store results in cache

Implementation

void set(String query, List<T> results) {
  final normalizedQuery = _normalizeQuery(query);

  // Remove oldest entry if cache is full
  if (_cache.length >= maxSize && !_cache.containsKey(normalizedQuery)) {
    _evictLeastRecentlyUsed();
    _evictions++;
  }

  _cache[normalizedQuery] = _CacheEntry(
    results: List<T>.from(results), // Store copy to prevent external modification
    timestamp: DateTime.now(),
    lastAccessed: DateTime.now(),
    accessCount: 0,
  );
}