public final class LruNormalizedCache extends NormalizedCache
NormalizedCache backed by an in memory Cache. Can be configured with an optional secondaryCache
NormalizedCache, which will be used as a backup if a Record is not present in the primary cache.
A common configuration is to have secondary SQL cache.| Modifier and Type | Method and Description |
|---|---|
void |
clearAll()
Clears all records from the cache.
|
void |
clearPrimaryCache()
Clears all records from the in-memory LRU cache.
|
void |
clearSecondaryCache()
Clear all records from the secondary cache.
|
Record |
loadRecord(java.lang.String key,
CacheHeaders cacheHeaders) |
java.util.Set<java.lang.String> |
merge(Record apolloRecord,
CacheHeaders cacheHeaders) |
NormalizedCache |
secondaryCache() |
loadRecords, merge, recordAdapter@Nullable public NormalizedCache secondaryCache()
@Nullable public Record loadRecord(@Nonnull java.lang.String key, @Nonnull CacheHeaders cacheHeaders)
loadRecord in class NormalizedCachekey - The key of the record to read.cacheHeaders - The cache headers associated with the request which generated this record.Record for key. If not present return null.@Nonnull
public java.util.Set<java.lang.String> merge(@Nonnull
Record apolloRecord,
@Nonnull
CacheHeaders cacheHeaders)
merge in class NormalizedCacheapolloRecord - The Record to merge.cacheHeaders - The CacheHeaders associated with the request which generated this record.Record.mergeWith(Record).public void clearAll()
NormalizedCacheApolloClient.clearNormalizedCache() for a thread-safe access to
this method.clearAll in class NormalizedCachepublic void clearPrimaryCache()
ApolloStore, obtained from
ApolloClient.apolloStore().public void clearSecondaryCache()
ApolloStore, obtained from
ApolloClient.apolloStore().