getObjectsOverCapacity method

  1. @override
Future<List<CacheObject>> getObjectsOverCapacity(
  1. int capacity
)
override

Gets the list of CacheObject that can be removed if the repository is over capacity.

The exact implementation is up to the repository, but implementations should return a preferred list of items. For example, the least recently accessed

Implementation

@override
Future<List<CacheObject>> getObjectsOverCapacity(int capacity) async {
  return CacheObject.fromMapList(await db!.query(
    _tableCacheObject,
    columns: null,
    orderBy: '${CacheObject.columnTouched} DESC',
    where: '${CacheObject.columnTouched} < ?',
    whereArgs: [
      DateTime.now().subtract(const Duration(days: 1)).millisecondsSinceEpoch
    ],
    limit: 100,
    offset: capacity,
  ));
}