has method
Checks if a key exists in the cache using the default driver.
Returns true if the key exists and hasn't expired, false otherwise.
Throws CacheException if the key is empty or if the operation fails.
Implementation
@override
Future<bool> has(String key) async {
_validator.validateKey(key);
try {
final driver = _driverRegistry.getDefaultDriver();
final exists = await driver.has(key);
_statisticsManager.updateStats(
_driverRegistry.getDefaultDriverName(),
hit: exists,
operation: 'has',
);
return exists;
} catch (e) {
_statisticsManager.updateStats(
_driverRegistry.getDefaultDriverName(),
hit: false,
operation: 'has',
error: true,
);
throw CacheException('Failed to check cache item "$key": $e');
}
}