put method
Inserts an item into the cache.
key
: The key to store the item against.value
: The item to be cached.ttl
: The time-to-live duration for the item. Defaults to 1 minutes.
Implementation
void put(String key, T value, {Duration ttl = const Duration(minutes: 1)}) {
_logger.debug('Putting item with key: $key');
if (_currentSize == _maxSize) _evictLRU();
_cache[key] = TCacheItem(value, ttl);
_currentSize++;
_startCleaningIfNeeded(); // Start cleaning if first item is added
}