Package org.molgenis.data.cache.l1
Class L1Cache
- java.lang.Object
-
- org.molgenis.data.cache.l1.L1Cache
-
- All Implemented Interfaces:
org.molgenis.data.transaction.TransactionListener
@Component public class L1Cache extends Object implements org.molgenis.data.transaction.TransactionListener
Caches entities within a transaction to speed up queries within those transactions. Each transaction has its own cache. When the transaction is committed the cache is removed.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddoCleanupAfterCompletion(String transactionId)Optional<CacheHit<org.molgenis.data.Entity>>get(String entityTypeId, Object id, org.molgenis.data.meta.model.EntityType entityType)Retrieves an entity from the L1 cache based on a combination of entity name and entity id.voidput(String entityTypeId, org.molgenis.data.Entity entity)Puts an entity into the L1 cache, if the cache exists for the current thread.voidtransactionStarted(String transactionId)
-
-
-
Method Detail
-
transactionStarted
public void transactionStarted(String transactionId)
- Specified by:
transactionStartedin interfaceorg.molgenis.data.transaction.TransactionListener
-
doCleanupAfterCompletion
public void doCleanupAfterCompletion(String transactionId)
- Specified by:
doCleanupAfterCompletionin interfaceorg.molgenis.data.transaction.TransactionListener
-
get
public Optional<CacheHit<org.molgenis.data.Entity>> get(String entityTypeId, Object id, org.molgenis.data.meta.model.EntityType entityType)
Retrieves an entity from the L1 cache based on a combination of entity name and entity id.- Parameters:
entityTypeId- name of the entity to retrieveid- id value of the entity to retrieve- Returns:
- an
Optionalof which the CacheHit contains anEntityor is empty if deletion of this entity is stored in the cache, or Optional.empty() if there's no information available about this entity in the cache
-
put
public void put(String entityTypeId, org.molgenis.data.Entity entity)
Puts an entity into the L1 cache, if the cache exists for the current thread.- Parameters:
entityTypeId- name of the entity to put into the cacheentity- the entity to put into the cache
-
-