Class InstrumentedStorageCache
java.lang.Object
ydocumentcartpackage.persistence.polyglot.repository.documentcart.storage.cache.BaseStorageCache
ydocumentcartpackage.persistence.polyglot.repository.documentcart.storage.cache.InstrumentedStorageCache
- All Implemented Interfaces:
StorageCache
-
Nested Class Summary
Nested 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
ConstructorsConstructorDescriptionInstrumentedStorageCache(BaseStorageCache targetCache, com.codahale.metrics.MetricRegistry metricRegistry, String repositoryName) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcacheDocuments(QueryResult queryResult) protected StorageCache.CacheContextcreateCacheContext(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 targetFunction) protected BaseStorageCache.CacheFlushActionbooleanprotected booleanisFindInStorageFirst(Query query) Method to verify whether a query should be called to the storage firstvoidbooleanbooleanMethods inherited from class ydocumentcartpackage.persistence.polyglot.repository.documentcart.storage.cache.BaseStorageCache
findInCache, initCacheContext
-
Constructor Details
-
InstrumentedStorageCache
public InstrumentedStorageCache(BaseStorageCache targetCache, com.codahale.metrics.MetricRegistry metricRegistry, String repositoryName)
-
-
Method Details
-
postConstruct
@PostConstruct public void postConstruct() -
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() -
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 targetFunction) - Specified by:
findInStoragein classBaseStorageCache
-
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.
-
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.
-
getFlushAction
- Specified by:
getFlushActionin classBaseStorageCache
-
createCacheContext
protected StorageCache.CacheContext createCacheContext(Storage storage, BaseStorageCache.CacheFlushAction flushAction) - Specified by:
createCacheContextin classBaseStorageCache
-