set method

  1. @override
Future<void> set(
  1. String key,
  2. Uint8List value, [
  3. DistributedCacheEntryOptions? options
])
override

Sets a value with the given key.

key must not be null. value must not be null. options can be provided to configure expiration.

Implementation

@override
Future<void> set(
  String key,
  Uint8List value, [
  DistributedCacheEntryOptions? options,
]) async {
  final entry = _cache.createEntry(key)..value = value;

  if (options != null) {
    entry
      ..absoluteExpiration = options.absoluteExpiration
      ..absoluteExpirationRelativeToNow =
          options.absoluteExpirationRelativeToNow
      ..slidingExpiration = options.slidingExpiration;
  }

  // Commit the entry
  if (entry is CacheEntryInternal) {
    _cache.finalizeEntry(entry);
  }
}