cache static method

HealthCheckFunction cache([
  1. String? store
])

A check that writes a key to the cache and reads it back. store is a store name of AppConfig.cache, default store when null.

Implementation

static HealthCheckFunction cache([String? store]) {
  Future<bool> check() async {
    Cache cache = Cache();
    if (store != null) cache.store(store);
    String key = 'dox_health_check';
    await cache.put(key, 'ok', duration: const Duration(minutes: 1));
    return await cache.get(key) == 'ok';
  }

  return check;
}