setCache method

void setCache(
  1. String key,
  2. Cache cache
)

Stores a cache entry for the specified key.

Implementation

void setCache(String key, Cache cache) {
  switch (cacheSource) {
    case CacheSource.memory:
      _cacheMemory[key] = cache;
      break;
    case CacheSource.file:
      var file = File(
        joinPaths([FinchApp.config.pathCache, "cache_$key.json"]),
      );
      file.createSync(recursive: true);
      file.writeAsStringSync(cache.toJsonString());
      break;
  }
}