cache method

RouteCache cache({
  1. Duration cacheDuration = const Duration(minutes: 10),
  2. List<CacheParam> cacheType = const [CacheParam.method, CacheParam.path],
  3. CacheSource cacheSource = CacheSource.memory,
})

Wraps the current FinchRoute with a RouteCache to enable response caching.

cacheDuration defines how long the cache should live (default 10 minutes). cacheType defines what parts of the request form the cache key. cacheSource defines where the cache is stored.

Implementation

RouteCache cache({
  Duration cacheDuration = const Duration(minutes: 10),
  List<CacheParam> cacheType = const [CacheParam.method, CacheParam.path],
  CacheSource cacheSource = CacheSource.memory,
}) {
  return RouteCache(
    apiDoc: apiDoc,
    auth: auth,
    cacheDuration: cacheDuration,
    cacheSource: cacheSource,
    cacheType: cacheType,
    controller: controller,
    extraPath: extraPath,
    key: key,
    methods: methods,
    handle: index ??
        () async {
          throw Exception(
              'Index is required in this route for cache functionality: $path');
        },
    path: path,
    permissions: permissions,
    ports: ports,
    hosts: hosts,
    title: title,
    middlewares: middlewares,
    children: children,
    params: params,
    excludePaths: excludePaths,
    widget: widget,
  );
}