/** * Clear all entries from the normalized cache. This is synchronous operation and will be executed int the current * thread * * @return {@code true} if operation succeed, {@code false} otherwise */ public boolean clearNormalizedCache() { return apolloStore.clearAll().execute(); }
Set<String> rollbackOptimisticUpdates(final InterceptorRequest request) { try { return apolloStore.rollbackOptimisticUpdates(request.uniqueId).execute(); } catch (Exception e) { logger.e(e, "failed to rollback operation optimistic updates, for: %s", request.operation); return Collections.emptySet(); } }
@Override public void run() { try { apolloStore.rollbackOptimisticUpdatesAndPublish(request.uniqueId).execute(); } catch (Exception e) { logger.e(e, "failed to rollback operation optimistic updates, for: %s", request.operation); } } });
@Override public void run() { try { if (request.optimisticUpdates.isPresent()) { Operation.Data optimisticUpdates = request.optimisticUpdates.get(); apolloStore.writeOptimisticUpdatesAndPublish(request.operation, optimisticUpdates, request.uniqueId) .execute(); } } catch (Exception e) { logger.e(e, "failed to write operation optimistic updates, for: %s", request.operation); } } });
InterceptorResponse resolveFromCache(InterceptorRequest request) throws ApolloException { ResponseNormalizer<Record> responseNormalizer = apolloStore.cacheResponseNormalizer(); //noinspection unchecked ApolloStoreOperation<Response> apolloStoreOperation = apolloStore.read(request.operation, responseFieldMapper, responseNormalizer, request.cacheHeaders); Response cachedResponse = apolloStoreOperation.execute(); if (cachedResponse.data() != null) { logger.d("Cache HIT for operation %s", request.operation); return new InterceptorResponse(null, cachedResponse, responseNormalizer.records()); } logger.d("Cache MISS for operation %s", request.operation); throw new ApolloException(String.format("Cache miss for operation %s", request.operation)); }