Package org.molgenis.data.cache.l1
Class L1Cache
- java.lang.Object
-
- org.molgenis.data.cache.l1.L1Cache
-
- All Implemented Interfaces:
TransactionListener
@Component public class L1Cache extends Object implements 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<Entity>>get(EntityType entityType, Object entityId)Optional<CacheHit<Entity>>get(EntityType entityType, Object entityId, Fetch fetch)Retrieves an entity from the L1 cache based on a combination of entity name and entity id.voidput(Entity entity)Puts an entity into the L1 cache, if the cache exists for the current thread.voidtransactionStarted(String transactionId)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.molgenis.data.transaction.TransactionListener
afterCommitTransaction, commitTransaction, rollbackTransaction
-
-
-
-
Method Detail
-
transactionStarted
public void transactionStarted(String transactionId)
- Specified by:
transactionStartedin interfaceTransactionListener
-
doCleanupAfterCompletion
public void doCleanupAfterCompletion(String transactionId)
- Specified by:
doCleanupAfterCompletionin interfaceTransactionListener
-
get
public Optional<CacheHit<Entity>> get(EntityType entityType, Object entityId)
-
get
public Optional<CacheHit<Entity>> get(EntityType entityType, Object entityId, @Nullable @CheckForNull Fetch fetch)
Retrieves an entity from the L1 cache based on a combination of entity name and entity id.- Parameters:
entityType- entity typeentityId- id value of the entity to retrievefetch- containing attributes to retrieve, can be null- 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(Entity entity)
Puts an entity into the L1 cache, if the cache exists for the current thread.
-
-