public abstract class BaseCacheService<TKey,T extends ObjectWithId<TKey>,TDataStore> extends BaseComponent<TKey,TDataStore> implements CacheService<TKey,T,TDataStore>, BaseStorageService<TKey,T,TDataStore>
| Modifier and Type | Field and Description |
|---|---|
protected java.util.concurrent.ConcurrentMap<T,java.lang.Long> |
cache |
protected Registry |
registry |
| Modifier | Constructor and Description |
|---|---|
protected |
BaseCacheService(DataStoreContext<TKey,TDataStore> dataStoreContext,
Registry registry) |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<T> |
delete(java.util.function.Predicate<? super T> predicate)
Deletes a
T from the cache |
java.util.Optional<T> |
delete(T t)
Deletes a
T from the cache |
java.util.Optional<T> |
deleteOne(java.util.function.Predicate<? super T> predicate)
Deletes a
T from the cache |
java.util.concurrent.CompletableFuture<java.lang.Boolean> |
deleteOne(TKey id)
Attempts to delete a matching
document with
the provided id |
java.util.List<T> |
getAll(java.util.function.Predicate<? super T> predicate) |
java.util.Set<T> |
getAllAsSet() |
java.util.concurrent.CompletableFuture<java.util.List<TKey>> |
getAllIds() |
java.lang.Runnable |
getCacheInvalidationTask() |
java.util.Optional<T> |
getOne(java.util.function.Predicate<? super T> predicate) |
java.util.concurrent.CompletableFuture<java.util.Optional<T>> |
getOne(TKey id)
Attempts to find a matching
document with
the provided id |
java.util.concurrent.CompletableFuture<java.util.List<T>> |
insert(java.util.List<T> list) |
java.util.concurrent.CompletableFuture<java.util.Optional<T>> |
insertOne(T t) |
getDataStoreContext, getTKeyClass, parseclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitstartCacheInvalidationTask, stopCacheInvalidationTaskgenerateEmpty, parseAndDeleteOne, parseAndGetOnedeleteOne, getAll, getOne, getTClassprotected Registry registry
protected java.util.concurrent.ConcurrentMap<T extends ObjectWithId<TKey>,java.lang.Long> cache
protected BaseCacheService(DataStoreContext<TKey,TDataStore> dataStoreContext, Registry registry)
public java.lang.Runnable getCacheInvalidationTask()
getCacheInvalidationTask in interface CacheService<TKey,T extends ObjectWithId<TKey>,TDataStore>public java.util.Set<T> getAllAsSet()
getAllAsSet in interface CacheService<TKey,T extends ObjectWithId<TKey>,TDataStore>public java.util.concurrent.CompletableFuture<java.util.Optional<T>> insertOne(T t)
insertOne in interface StorageService<TKey,T extends ObjectWithId<TKey>,TDataStore>t - document to insertOptional containing the inserted document
if successful, otherwise Optional.empty()public java.util.concurrent.CompletableFuture<java.util.List<T>> insert(java.util.List<T> list)
insert in interface StorageService<TKey,T extends ObjectWithId<TKey>,TDataStore>list - List of documents to insertList of all documents that were successfully insertedpublic java.util.concurrent.CompletableFuture<java.util.Optional<T>> getOne(TKey id)
StorageServicedocument with
the provided idgetOne in interface StorageService<TKey,T extends ObjectWithId<TKey>,TDataStore>id - TKey to query repository withOptional containing a matching document
if successful, otherwise Optional.empty()public java.util.concurrent.CompletableFuture<java.lang.Boolean> deleteOne(TKey id)
StorageServicedocument with
the provided iddeleteOne in interface StorageService<TKey,T extends ObjectWithId<TKey>,TDataStore>id - TKey to query repository withpublic java.util.concurrent.CompletableFuture<java.util.List<TKey>> getAllIds()
getAllIds in interface StorageService<TKey,T extends ObjectWithId<TKey>,TDataStore>List of all ids in the repositorypublic java.util.Optional<T> deleteOne(java.util.function.Predicate<? super T> predicate)
CacheServiceT from the cachedeleteOne in interface CacheService<TKey,T extends ObjectWithId<TKey>,TDataStore>predicate - of T to remove from cacheT if it was successfully removedpublic java.util.Optional<T> delete(T t)
CacheServiceT from the cachedelete in interface CacheService<TKey,T extends ObjectWithId<TKey>,TDataStore>t - T to remove from cacheT if it was successfully removedpublic java.util.List<T> delete(java.util.function.Predicate<? super T> predicate)
CacheServiceT from the cachedelete in interface CacheService<TKey,T extends ObjectWithId<TKey>,TDataStore>predicate - of T to remove from cachepublic java.util.List<T> getAll(java.util.function.Predicate<? super T> predicate)
getAll in interface CacheService<TKey,T extends ObjectWithId<TKey>,TDataStore>public java.util.Optional<T> getOne(java.util.function.Predicate<? super T> predicate)
getOne in interface CacheService<TKey,T extends ObjectWithId<TKey>,TDataStore>