deleteExpiredKeys method
Removes all expired keys. Deletes are local-only — they are
NOT appended to the commit log, so an expiry sweep never
advances the local commitId and never propagates to other
secondaries via sync. Expiry is treated as backend
maintenance, not a sync-worthy mutation; clients drop expired
keys independently using their own TTL bookkeeping.
Implementation
@override
Future<bool> deleteExpiredKeys() async {
var result = true;
try {
var expiredKeys = await (await getExpiredKeys()).toList();
if (expiredKeys.isNotEmpty) {
await Future.forEach(expiredKeys, (expiredKey) async {
await remove(expiredKey, skipCommit: true);
});
} else {
_logger.finest('notification key store. No expired notifications');
}
} on Exception catch (e) {
result = false;
_logger.severe('Exception in deleteExpired keys: ${e.toString()}');
throw DataStoreException(
'exception in deleteExpiredKeys: ${e.toString()}');
} on HiveError catch (error) {
_logger.severe('Error occurred in notification keystore: $error');
throw DataStoreException(error.message);
}
return result;
}