set method

Future<void> set(
  1. String key,
  2. T data, {
  3. Duration? ttl,
})

Set cached data

Implementation

Future<void> set(String key, T data, {Duration? ttl}) async {
  try {
    final json = {
      'data': data,
      'cachedAt': DateTime.now().toIso8601String(),
    };
    await storage.save('$prefix$key', jsonEncode(json));
  } catch (e) {
    debugPrint('Error writing to disk cache: $e');
  }
}