put method

void put(
  1. String key,
  2. String response, {
  3. Duration? ttl,
})

Stores response under key.

Implementation

void put(String key, String response, {Duration? ttl}) {
  if (_entries.length >= maxEntries) {
    // Evict the oldest entry (first inserted, since Dart Maps are insertion
    // ordered).
    if (_entries.isNotEmpty) _entries.remove(_entries.keys.first);
  }
  _entries[key] = _CacheEntry(
    response,
    ttl == null ? null : DateTime.now().add(ttl),
  );
}