Skip to content

Instantly share code, notes, and snippets.

Created Nov 17, 2017
What would you like to do?
public List<AlertEntry> getAlertForServiceId(String serviceId) {
final String sql = "serviceId = ?";
// create the sql query object with entity type of the value part of the key value cache
SqlQuery<String, AlertEntry> query = new SqlQuery<>(AlertEntry.class, sql);
// set the query params
//then execute it over the cache
return Optional.ofNullable(getAlertsCache().query(query).getAll().stream().map(stringAlertEntryEntry -> stringAlertEntryEntry.getValue()).collect(Collectors.toList()))
.orElseThrow(() -> new ResourceNotFoundException(String.format("Alert for %s not found", serviceId)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment