Class ThreadLocalDocumentCache
java.lang.Object
ydocumentcartpackage.persistence.polyglot.repository.documentcart.storage.cache.BaseStorageCache
ydocumentcartpackage.persistence.polyglot.repository.documentcart.storage.cache.ThreadLocalDocumentCache
- All Implemented Interfaces:
StorageCache
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classNested classes/interfaces inherited from class ydocumentcartpackage.persistence.polyglot.repository.documentcart.storage.cache.BaseStorageCache
BaseStorageCache.CacheFlushActionNested classes/interfaces inherited from interface ydocumentcartpackage.persistence.polyglot.repository.documentcart.storage.cache.StorageCache
StorageCache.CacheContext, StorageCache.LoadFromStorageStrategy -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcacheDocuments(QueryResult queryResult) createCacheContext(Storage storage, BaseStorageCache.CacheFlushAction flushAction) protected Optional<QueryResult>findInCache(Query query) Method to find a query result in cache.protected QueryResultfindInStorage(Query baseQuery, StorageCache.LoadFromStorageStrategy loadFromStorageStrategy) protected BaseStorageCache.CacheFlushActionbooleanprotected booleanisFindInStorageFirst(Query query) Method to verify whether a query should be called to the storage firstbooleanbooleanMethods inherited from class ydocumentcartpackage.persistence.polyglot.repository.documentcart.storage.cache.BaseStorageCache
findInCache, initCacheContext
-
Constructor Details
-
ThreadLocalDocumentCache
public ThreadLocalDocumentCache()
-
-
Method Details
-
findInCache
Description copied from class:BaseStorageCacheMethod to find a query result in cache. Is called only if returnstrue- Specified by:
findInCachein classBaseStorageCache- Parameters:
query- the query used to find documents- Returns:
Optional.empty()if no documents has been found in cache that meets the query, otherwise an optional of
-
findInStorage
protected QueryResult findInStorage(Query baseQuery, StorageCache.LoadFromStorageStrategy loadFromStorageStrategy) - Specified by:
findInStoragein classBaseStorageCache
-
save
- Parameters:
document- document to be saved- Returns:
trueif document has been stored in cache. The save of document in storage will be done when the is closed. Otherwise, returnsfalseand document should be saved in storage manually.
-
remove
- Parameters:
document- document to be removed- Returns:
trueif document has been marked for removal in cache. The removal will be done in storage when the is closed. Otherwise, returnsfalseand document should be removed from storage manually.
-
isFindInStorageFirst
Description copied from class:BaseStorageCacheMethod to verify whether a query should be called to the storage first- Specified by:
isFindInStorageFirstin classBaseStorageCache- Parameters:
query- the query used to find documents- Returns:
trueif query should be called to the storage first
-
cacheDocuments
- Specified by:
cacheDocumentsin classBaseStorageCache
-
isCacheActive
public boolean isCacheActive() -
getFlushAction
- Specified by:
getFlushActionin classBaseStorageCache
-
createCacheContext
protected ThreadLocalDocumentCache.ThreadLocalCacheContext createCacheContext(Storage storage, BaseStorageCache.CacheFlushAction flushAction) - Specified by:
createCacheContextin classBaseStorageCache
-