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