getKeys method

  1. @override
Future<List<String>> getKeys({
  1. int? limit,
  2. int? offset,
})
override

Returns a list of all keys in the cache.

Throws a CacheException if there is an error retrieving the keys. The limit and offset parameters can be used to paginate the results.

Implementation

@override
Future<List<String>> getKeys({int? limit, int? offset}) async {
  final keys = _cache.keys.toList();
  if (limit == null && offset == null) {
    return keys;
  }

  final startIndex = offset ?? 0;
  final endIndex = limit == null ? keys.length : startIndex + limit;

  return keys.skip(startIndex).take(endIndex - startIndex).toList();
}