Class DbEntityCache
java.lang.Object
org.camunda.bpm.engine.impl.db.entitymanager.cache.DbEntityCache
A simple first level cache for
Entities.- Author:
- Daniel Meyer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map<Class<?>,Map<String, CachedDbEntity>> The cache itself: maps entity types (classes) to maps indexed by id (primary key).protected DbEntityCacheKeyMappingprotected static final EnginePersistenceLogger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAllows checking whether the provided entity is present in the cache<T extends DbEntity>
Tget an object from the cachegetCachedEntity(Class<?> type, String id) Looks up an entity in the cache.getCachedEntity(DbEntity dbEntity) Looks up an entity in the cache.getEntitiesByType(Class<T> type) booleanAllows checking whether the provided entity is present in the cache and is marked to be deleted.booleanisPersistent(DbEntity dbEntity) Allows checking whether the provided entity is present in the cache and isDbEntityState.PERSISTENT.booleanisTransient(DbEntity dbEntity) Allows checking whether the provided entity is present in the cache and isDbEntityState.TRANSIENT.protected voidputInternal(CachedDbEntity entityToAdd) voidPut aDbEntityState.MERGEDobject into the cache.voidPut aDbEntityState.PERSISTENTobject into the cache.voidPut a new,DbEntityState.TRANSIENTobject into the cache.booleanRemove an entity from the cachevoidremove(CachedDbEntity cachedDbEntity) voidsetDeleted(DbEntity dbEntity) Sets an object to a deleted state.voidundoDelete(DbEntity dbEntity)
-
Field Details
-
LOG
-
cachedEntites
The cache itself: maps entity types (classes) to maps indexed by id (primary key). The motivation for indexing by type (class) is a) multiple entities of different types could have the same value as primary key. In the process engine, TaskEntity and HistoricTaskEntity have the same id value. b) performance (?) -
cacheKeyMapping
-
-
Constructor Details
-
DbEntityCache
public DbEntityCache() -
DbEntityCache
-
-
Method Details
-
get
get an object from the cache- Parameters:
type- the type of the objectid- the id of the object- Returns:
- the object or 'null' if the object is not in the cache
- Throws:
ProcessEngineException- if an object for the given id can be found but is of the wrong type.
-
getEntitiesByType
-
getCachedEntity
Looks up an entity in the cache.- Parameters:
type- the type of the objectid- the id of the CachedEntity to lookup- Returns:
- the cached entity or null if the entity does not exist.
-
getCachedEntity
Looks up an entity in the cache.- Parameters:
dbEntity- the entity for which the CachedEntity should be looked up- Returns:
- the cached entity or null if the entity does not exist.
-
putTransient
Put a new,DbEntityState.TRANSIENTobject into the cache.- Parameters:
e- the object to put into the cache
-
putPersistent
Put aDbEntityState.PERSISTENTobject into the cache.- Parameters:
e- the object to put into the cache
-
putMerged
Put aDbEntityState.MERGEDobject into the cache.- Parameters:
e- the object to put into the cache
-
putInternal
-
remove
Remove an entity from the cache- Parameters:
e- the entity to remove- Returns:
-
remove
- Parameters:
cachedDbEntity-
-
contains
Allows checking whether the provided entity is present in the cache- Parameters:
dbEntity- the entity to check- Returns:
- true if the the provided entity is present in the cache
-
isPersistent
Allows checking whether the provided entity is present in the cache and isDbEntityState.PERSISTENT.- Parameters:
dbEntity- the entity to check- Returns:
- true if the provided entity is present in the cache and is
DbEntityState.PERSISTENT.
-
isDeleted
Allows checking whether the provided entity is present in the cache and is marked to be deleted.- Parameters:
dbEntity- the entity to check- Returns:
- true if the provided entity is present in the cache and is marked to be deleted
-
isTransient
Allows checking whether the provided entity is present in the cache and isDbEntityState.TRANSIENT.- Parameters:
dbEntity- the entity to check- Returns:
- true if the provided entity is present in the cache and is
DbEntityState.TRANSIENT.
-
getCachedEntities
-
setDeleted
Sets an object to a deleted state. It will not be removed from the cache but transition to one of the DELETED states, depending on it's current state.- Parameters:
dbEntity- the object to mark deleted.
-
undoDelete
-