put method

  1. @override
Future<void> put(
  1. String key,
  2. CacheItem value
)
override

Stores a value in the cache with the given key.

The value is wrapped in a CacheItem object, which allows for optional expiry.

Throws a CacheException if there is an error storing the data.

Implementation

@override
Future<void> put(String key, CacheItem<dynamic> value) async {
  if (enableEncryption) {
    final encryptedValue = _encrypt(jsonEncode(value.toJson()));
    _cache[key] = encryptedValue;
  } else {
    _cache[key] = value;
  }
}