write method
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 {
final ttl = options.cacheTime.duration;
final riverpodKey = Helpers.computeRiverpodKey(key);
final expiresAt = Helpers.computeExpirationTime(ttl: ttl);
final persist = PersistedSpValue(
key: riverpodKey,
data: value,
expiresAt: expiresAt,
destroyKey: options.destroyKey,
);
final encoded = jsonEncode(persist.toJson());
await prefs.setString(riverpodKey, encoded);
}