delete method
Deletes the value associated with the given key
.
Throws an ArgumentError if the key is empty. Throws a CacheException if there is an error deleting the data.
Implementation
Future<void> delete(String key) async {
if (key.isEmpty) {
throw ArgumentError('Key cannot be empty');
}
try {
await _cacheAdapter.delete(key);
// Record delete operation in analytics
_analytics.recordDelete(key);
} on HiveError catch (e) {
_log.severe('Failed to delete data from cache (HiveError): $e');
throw CacheException('Failed to delete data from cache: ${e.message}');
} catch (e) {
_log.severe('Failed to delete data from cache (Unknown Error): $e');
throw CacheException('Failed to delete data from cache: $e');
}
}