get method
Retrieves the value mapped to key, or null if no mapping
exists. Implementations may also throw a backend-specific
not-found exception (e.g. KeyNotFoundException) instead of
returning null — consult the concrete impl.
Implementation
@override
Future<AtData?> get(String key) async {
key = key.toLowerCase();
AtData? value;
try {
String hiveKey = HiveKeyStoreHelper.prepareKey(key);
value = await (getBox() as LazyBox).get(hiveKey);
value?.key = hiveKey;
// load metadata for hive_key
// compare availableAt with time.now()
//return only between ttl and ttb
} on Exception catch (exception) {
logger.severe('HiveAtKeyValueStore get exception: $exception');
throw DataStoreException('exception in get: ${exception.toString()}');
} on HiveError catch (error) {
logger.severe('HiveAtKeyValueStore get error: $error');
await _restartHiveBox(error);
throw DataStoreException(error.message);
}
if (value == null) {
throw KeyNotFoundException('$key does not exist in keystore',
intent: Intent.fetchData,
exceptionScenario: ExceptionScenario.keyNotFound);
}
return value;
}