public abstract class BaseCachedRepository<TKey,T extends ObjectWithId<TKey>,C extends CacheService<TKey,T,TDataStore>,TDataStore> extends BaseRepository<TKey,T,TDataStore> implements CachedRepository<TKey,T,C,TDataStore>
| Modifier | Constructor and Description |
|---|---|
protected |
BaseCachedRepository(DataStoreContext<TKey,TDataStore> dataStoreContext) |
| Modifier and Type | Method and Description |
|---|---|
<K> java.util.concurrent.CompletableFuture<K> |
applyFromDBThroughCache(java.util.function.Supplier<K> fromDB,
java.util.function.BiFunction<C,K,K> cacheTransformer)
Usually used for editing model data
|
<K> java.util.concurrent.CompletableFuture<java.util.Optional<K>> |
applyFromDBThroughCacheConditionally(java.util.function.Supplier<java.util.Optional<K>> fromDB,
java.util.function.BiFunction<C,K,java.util.Optional<K>> cacheTransformer)
Usually used for editing model data
|
<K> java.util.concurrent.CompletableFuture<K> |
applyFromDBToCache(java.util.function.Supplier<K> fromDB,
java.util.function.BiConsumer<C,K> toCache)
Usually used when (updated) data from DB needs to be applied to cache
|
<K> java.util.concurrent.CompletableFuture<java.util.Optional<K>> |
applyFromDBToCacheConditionally(java.util.function.Supplier<java.util.Optional<K>> fromDB,
java.util.function.BiConsumer<C,K> toCache)
Usually used when (updated) data from DB needs to be applied to cache
|
<K> java.util.concurrent.CompletableFuture<K> |
applyThroughBoth(java.util.function.Function<C,K> cacheTransformer,
java.util.function.Function<java.util.Optional<K>,K> dbTransformer)
Usually used for editing model data
|
<K> java.util.concurrent.CompletableFuture<java.util.Optional<K>> |
applyThroughBothConditionally(java.util.function.Function<C,java.util.Optional<K>> cacheTransformer,
java.util.function.Function<K,K> dbTransformer)
Usually used for retrieving or editing model data
|
<K> java.util.concurrent.CompletableFuture<java.util.Optional<K>> |
applyToBothConditionally(java.util.function.Function<C,java.util.Optional<K>> cacheTransformer,
java.util.function.Supplier<java.util.Optional<K>> dbSupplier)
Usually used for retrieving or editing model data
|
getCreatedUtcgetDataStoreContext, getTKeyClass, parseclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetRepositoryCacheServicegetCreatedUtcdeleteOne, deleteOne, generateEmpty, getAll, getAllIds, getOne, getOne, getTClass, insert, insertOne, parseAndDeleteOne, parseAndGetOnegetDataStoreContext, getTKeyClass, parse, parseUnsafegenerateEmpty, parseAndDeleteOne, parseAndGetOneprotected BaseCachedRepository(DataStoreContext<TKey,TDataStore> dataStoreContext)
public <K> java.util.concurrent.CompletableFuture<K> applyFromDBToCache(java.util.function.Supplier<K> fromDB,
java.util.function.BiConsumer<C,K> toCache)
CachedRepositoryUsually used when (updated) data from DB needs to be applied to cache
toCache will run if and only if:
applyFromDBToCache in interface CachedRepository<TKey,T extends ObjectWithId<TKey>,C extends CacheService<TKey,T,TDataStore>,TDataStore>K - The type returned from the cache and databasefromDB - Supplier retrieving data from DBtoCache - BiConsumer applying DB data to cachepublic <K> java.util.concurrent.CompletableFuture<java.util.Optional<K>> applyFromDBToCacheConditionally(java.util.function.Supplier<java.util.Optional<K>> fromDB,
java.util.function.BiConsumer<C,K> toCache)
CachedRepositoryUsually used when (updated) data from DB needs to be applied to cache
toCache will run if and only if:
Optional result from fromDB is presentapplyFromDBToCacheConditionally in interface CachedRepository<TKey,T extends ObjectWithId<TKey>,C extends CacheService<TKey,T,TDataStore>,TDataStore>K - The type returned from the cache and databasefromDB - Supplier retrieving data from DBtoCache - BiConsumer applying DB data to cache.public <K> java.util.concurrent.CompletableFuture<K> applyFromDBThroughCache(java.util.function.Supplier<K> fromDB,
java.util.function.BiFunction<C,K,K> cacheTransformer)
CachedRepositoryUsually used for editing model data
cacheTransformer will run if and only if:
applyFromDBThroughCache in interface CachedRepository<TKey,T extends ObjectWithId<TKey>,C extends CacheService<TKey,T,TDataStore>,TDataStore>K - The type returned from the cache and databasefromDB - Supplier retrieving data from DBcacheTransformer - BiFunction applying DB data to cachepublic <K> java.util.concurrent.CompletableFuture<java.util.Optional<K>> applyFromDBThroughCacheConditionally(java.util.function.Supplier<java.util.Optional<K>> fromDB,
java.util.function.BiFunction<C,K,java.util.Optional<K>> cacheTransformer)
CachedRepositoryUsually used for editing model data
cacheTransformer will run if and only if:
Optional result from fromDB is presentapplyFromDBThroughCacheConditionally in interface CachedRepository<TKey,T extends ObjectWithId<TKey>,C extends CacheService<TKey,T,TDataStore>,TDataStore>K - The type returned from the cache and databasefromDB - Supplier retrieving data from DBcacheTransformer - BiFunction applying DB data to cache. Will only be run if Optional is presentpublic <K> java.util.concurrent.CompletableFuture<K> applyThroughBoth(java.util.function.Function<C,K> cacheTransformer, java.util.function.Function<java.util.Optional<K>,K> dbTransformer)
CachedRepositoryUsually used for editing model data
cacheTransformer will run if and only if:
applyThroughBoth in interface CachedRepository<TKey,T extends ObjectWithId<TKey>,C extends CacheService<TKey,T,TDataStore>,TDataStore>K - The type returned by the cache and databasecacheTransformer - Function applying transformation to data in cache and returning new datadbTransformer - Function retrieving data from db.
Optional is the result of the cache function (will be empty if the cache or the result is not present)public <K> java.util.concurrent.CompletableFuture<java.util.Optional<K>> applyThroughBothConditionally(java.util.function.Function<C,java.util.Optional<K>> cacheTransformer, java.util.function.Function<K,K> dbTransformer)
CachedRepositoryUsually used for retrieving or editing model data
cacheTransformer will run if and only if:
dbTransformer will run if and only if:
Optional result from cacheTransformer is presentapplyThroughBothConditionally in interface CachedRepository<TKey,T extends ObjectWithId<TKey>,C extends CacheService<TKey,T,TDataStore>,TDataStore>K - The type returned by the cache and databasecacheTransformer - Function applying transformation to data in cache and returning new datadbTransformer - Function applying transformation to data in dbK result from cachepublic <K> java.util.concurrent.CompletableFuture<java.util.Optional<K>> applyToBothConditionally(java.util.function.Function<C,java.util.Optional<K>> cacheTransformer, java.util.function.Supplier<java.util.Optional<K>> dbSupplier)
CachedRepositoryUsually used for retrieving or editing model data
cacheTransformer will run if and only if:
dbTransformer will run if and only if:
Optional result from cacheTransformer is not presentapplyToBothConditionally in interface CachedRepository<TKey,T extends ObjectWithId<TKey>,C extends CacheService<TKey,T,TDataStore>,TDataStore>K - The type returned by the cache and databasecacheTransformer - Function applying transformation to data in cache and returning new datadbSupplier - Supplier retrieving data from db. Will only be run if Optional is not presentK result from cache if present, otherwise from db