TCacheItem<T> constructor

TCacheItem<T>(
  1. T value,
  2. Duration ttl
)

Creates a new cache item with the given value and ttl.

Initializes the lastAccessTime to the current time and calculates the _expiryTime based on the ttl.

Implementation

TCacheItem(this.value, this.ttl) {
  lastAccessTime = DateTime.now();
  _expiryTime = lastAccessTime.add(ttl);
}