containsKeys method
Checks if the cache contains values associated with all the given keys
.
Returns a map where the keys are the original keys and the values are booleans indicating whether the key exists in the cache.
Throws a CacheException if there is an error checking the keys.
Implementation
@override
Future<Map<String, bool>> containsKeys(List<String> keys) async {
if (keys.isEmpty) return {};
final db = await database;
final placeholders = List.filled(keys.length, '?').join(',');
final result = await db.query(
'cache',
columns: ['key'],
where: 'key IN ($placeholders)',
whereArgs: keys,
);
final foundKeys = result.map((e) => e['key'] as String).toSet();
final Map<String, bool> containsMap = {};
for (final key in keys) {
containsMap[key] = foundKeys.contains(key);
}
return containsMap;
}