@Nonnull protected final Cache.Entry newEntry(long expiresIn) { return new Cache.Entry(mCounter.getAndIncrement(), currentTimeMillis() + expiresIn); }
@Override public void onSuccess(@Nonnull R result) { final String key = mRequest.getCacheKey(); final RequestType type = mRequest.getType(); if (key != null) { final long now = currentTimeMillis(); final Cache.Entry entry = new Cache.Entry(result, now + type.expiresIn); mCache.putIfNotExist(type.getCacheKey(key), entry); } switch (type) { case PURCHASE: case CHANGE_PURCHASE: case CONSUME_PURCHASE: // these requests might affect the state of purchases => we need to invalidate caches. // see Billing#onPurchaseFinished() also mCache.removeAll(RequestType.GET_PURCHASES.getCacheKeyType()); break; } super.onSuccess(result); }