/** * Store a profile interceptor result. * * @param result the profile interceptor result to be stored * @throws IOException if an error occurs */ protected void store(@Nonnull final ProfileInterceptorResult result) throws IOException { final String context = result.getStorageContext(); final String key = result.getStorageKey(); final String value = result.getStorageValue(); final Long expiration = result.getStorageExpiration(); // Create / update loop until we succeed or exhaust attempts. int attempts = 10; boolean success = false; do { success = storageService.create(context, key, value, expiration); if (!success) { // The record already exists, so we need to overwrite via an update. success = storageService.update(context, key, value, expiration); } } while (!success && attempts-- > 0); if (!success) { log.error("{} Exhausted retry attempts storing result '{}'", getLogPrefix(), result); } }
/** * Store a profile interceptor result. * * @param result the profile interceptor result to be stored * @throws IOException if an error occurs * @return boolean whether the record was stored successfully */ protected boolean storeResult(@Nonnull final ProfileInterceptorResult result) throws IOException { final String context = result.getStorageContext(); final String key = result.getStorageKey(); final String value = result.getStorageValue(); final Long expiration = result.getStorageExpiration(); // Create / update loop until we succeed or exhaust attempts. int attempts = 10; boolean success = false; do { success = getStorageService().create(context, key, value, expiration); if (!success) { // The record already exists, so we need to overwrite via an update. success = getStorageService().update(context, key, value, expiration); } } while (!success && attempts-- > 0); if (!success) { log.error("{} Exhausted retry attempts storing result '{}'", getLogPrefix(), result); } return success; }
/** * Store a profile interceptor result. * * @param result the profile interceptor result to be stored * @throws IOException if an error occurs * @return boolean whether the record was stored successfully */ protected boolean storeResult(@Nonnull final ProfileInterceptorResult result) throws IOException { final String context = result.getStorageContext(); final String key = result.getStorageKey(); final String value = result.getStorageValue(); final Long expiration = result.getStorageExpiration(); // Create / update loop until we succeed or exhaust attempts. int attempts = 10; boolean success = false; do { success = getStorageService().create(context, key, value, expiration); if (!success) { // The record already exists, so we need to overwrite via an update. success = getStorageService().update(context, key, value, expiration); } } while (!success && attempts-- > 0); if (!success) { log.error("{} Exhausted retry attempts storing result '{}'", getLogPrefix(), result); } return success; }