setJSONWithTimeout method

Future<void> setJSONWithTimeout(
  1. String key,
  2. dynamic data,
  3. Duration timeout
)

store (key, jsonData) pair. cache expires after timeout.

jsonData is converted to string using json.encode and stored as (JSON) String.

Implementation

Future<void> setJSONWithTimeout(
    String key, dynamic data, Duration timeout) async {
  String value = json.encode(data);
  await _writeString(key, value);
  await _setTimeout(key, timeout);
}