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 (!_isInitialized) await init();

  if (enableEncryption) {
    final encryptedValue = _encrypt(jsonEncode(value.toJson()));
    await _box.put(key, encryptedValue);
  } else {
    await _box.put(key, value);
  }
}