@Override
                                public void completed(final Boolean result) {
                                    if (result.booleanValue()) {
                                        callback.completed(result);
                                    } else {
                                        if (!complexCancellable.isCancelled()) {
                                            final int numRetries = count.incrementAndGet();
                                            if (numRetries >= maxUpdateRetries) {
                                                callback.failed(new HttpCacheUpdateException("Cache update failed after " + numRetries + " retries"));
                                            } else {
                                                attemptUpdateEntry(key, casOperation, complexCancellable, count, callback);
                                            }
                                        }
                                    }
                                }
Abstract cache backend for serialized objects capable of CAS (compare-and-swap) updates.

@since 5.0
httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AbstractSerializingAsyncCacheStorage.java