deleteExpired static method

Future<void> deleteExpired({
  1. bool lazy = false,
})

Delete all expired settings.

This is called automatically by the database when the app starts.

Parameters:

  • lazy: Whether to delete the expired settings in a lazy transaction. Defaults to false.

Implementation

static Future<void> deleteExpired({bool lazy = false}) async {
  final db = await DB.instance();
  final now = DateTime.now();

  if (lazy) {
    db.writeTxn(() async {
      db.kVs.where().expiresAtLessThan(now).deleteAll();
    });
  } else {
    await db.writeTxn(() async {
      await db.kVs.where().expiresAtLessThan(now).deleteAll();
    });
  }
}