newEntry function

CacheEntry newEntry(
  1. ValueGenerator generator,
  2. int seed, {
  3. String? key,
  4. DateTime? expiryTime,
  5. DateTime? creationTime,
  6. DateTime? accessTime,
  7. DateTime? updateTime,
  8. int? hitCount,
})

Creates a new CacheEntry with the provided ValueGenerator and seed

  • generator: The ValueGenerator to use
  • seed: The seed for the ValueGenerator
  • key: The cache key
  • expiryTime: The cache expiry time
  • creationTime: The cache creation time
  • accessTime: The cache accessTime
  • updateTime: The cache update time
  • hitCount: The cache hit count

Returns a fully initialized CacheEntry

Implementation

CacheEntry newEntry(ValueGenerator generator, int seed,
    {String? key,
    DateTime? expiryTime,
    DateTime? creationTime,
    DateTime? accessTime,
    DateTime? updateTime,
    int? hitCount}) {
  return CacheEntry(key ?? 'cache_key_$seed', generator.nextValue(seed),
      expiryTime ?? seed.minutes.fromNow, creationTime ?? DateTime.now(),
      accessTime: accessTime, updateTime: updateTime, hitCount: hitCount);
}