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
public class ThreadLocalDocumentCache extends BaseStorageCache
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classThreadLocalDocumentCache.CacheHolderstatic classThreadLocalDocumentCache.ThreadLocalCacheContext-
Nested classes/interfaces inherited from class ydocumentcartpackage.persistence.polyglot.repository.documentcart.storage.cache.BaseStorageCache
BaseStorageCache.CacheFlushAction
-
Nested classes/interfaces inherited from interface ydocumentcartpackage.persistence.polyglot.repository.documentcart.storage.cache.StorageCache
StorageCache.CacheContext, StorageCache.LoadFromStorageStrategy
-
-
Constructor Summary
Constructors Constructor Description ThreadLocalDocumentCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcacheDocuments(QueryResult queryResult)protected ThreadLocalDocumentCache.ThreadLocalCacheContextcreateCacheContext(Storage storage, BaseStorageCache.CacheFlushAction flushAction)protected java.util.Optional<QueryResult>findInCache(Query query)Method to find a query result in cache.protected QueryResultfindInStorage(Query baseQuery, StorageCache.LoadFromStorageStrategy loadFromStorageStrategy)protected BaseStorageCache.CacheFlushActiongetFlushAction()protected booleanisCacheActive()booleanremove(Document document)booleansave(Document document)-
Methods inherited from class ydocumentcartpackage.persistence.polyglot.repository.documentcart.storage.cache.BaseStorageCache
findInCache, initCacheContext
-
-
-
-
Method Detail
-
findInCache
protected java.util.Optional<QueryResult> findInCache(Query query)
Description copied from class:BaseStorageCacheMethod to find a query result in cache. Is called only if {@see #isCacheActive} 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 {@see QueryResult}
-
findInStorage
protected QueryResult findInStorage(Query baseQuery, StorageCache.LoadFromStorageStrategy loadFromStorageStrategy)
- Specified by:
findInStoragein classBaseStorageCache
-
save
public boolean save(Document document)
- 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 {@see CacheContext} is closed. Otherwise, returnsfalseand document should be saved in storage manually.
-
remove
public boolean remove(Document document)
- 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 {@see CacheContext} is closed. Otherwise, returnsfalseand document should be removed from storage manually.
-
cacheDocuments
public void cacheDocuments(QueryResult queryResult)
- Specified by:
cacheDocumentsin classBaseStorageCache
-
isCacheActive
protected boolean isCacheActive()
- Specified by:
isCacheActivein classBaseStorageCache
-
getFlushAction
protected BaseStorageCache.CacheFlushAction getFlushAction()
- Specified by:
getFlushActionin classBaseStorageCache
-
createCacheContext
protected ThreadLocalDocumentCache.ThreadLocalCacheContext createCacheContext(Storage storage, BaseStorageCache.CacheFlushAction flushAction)
- Specified by:
createCacheContextin classBaseStorageCache
-
-