write method

  1. @override
Future<void> write(
  1. String key,
  2. String value,
  3. StorageOptions options
)

Writes value associated with key.

This should create a new entry if key does not exist, or update the existing entry if it does.

Implementation

@override
Future<void> write(String key, String value, StorageOptions options) async {
  await _db.insert(_tableName, {
    'key': key,
    'json': value,
    'expireAt': switch (options.cacheTime.duration) {
      null => null,
      final Duration duration =>
        _currentTimestamp() + duration.inMilliseconds,
    },
    if (options.destroyKey != null) 'destroyKey': options.destroyKey,
  }, conflictAlgorithm: ConflictAlgorithm.replace);
}