Package org.molgenis.data.cache.utils
Class CombinedEntityCache
- java.lang.Object
-
- org.molgenis.data.cache.utils.CombinedEntityCache
-
public class CombinedEntityCache extends Object
-
-
Constructor Summary
Constructors Constructor Description CombinedEntityCache(EntityHydration entityHydration, com.google.common.cache.Cache<EntityKey,CacheHit<Map<String,Object>>> cache)Creates a newCombinedEntityCache
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidevict(Stream<EntityKey> entityKeys)voidevictAll(EntityType entityType)Evicts all entries from the cache that belong to a certain entityType.Optional<CacheHit<Entity>>getIfPresent(EntityType entityType, Object id)Optional<CacheHit<Entity>>getIfPresent(EntityType entityType, Object id, Fetch fetch)Retrieves an entity from the cache if present.voidput(Entity entity)Inserts an entity into the cache.voidputDeletion(EntityKey entityKey)Caches the deletion of an entity instance.
-
-
-
Constructor Detail
-
CombinedEntityCache
public CombinedEntityCache(EntityHydration entityHydration, com.google.common.cache.Cache<EntityKey,CacheHit<Map<String,Object>>> cache)
Creates a newCombinedEntityCache- Parameters:
entityHydration-EntityHydrationused to hydrate and dehydrate the entities and generate cache keyscache- theCacheto store theCacheHits in
-
-
Method Detail
-
putDeletion
public void putDeletion(EntityKey entityKey)
Caches the deletion of an entity instance.- Parameters:
entityKey- theEntityKeyof the deleted entity instance
-
evictAll
public void evictAll(EntityType entityType)
Evicts all entries from the cache that belong to a certain entityType.- Parameters:
entityType- the id of the entity whose entries are to be evicted
-
getIfPresent
public Optional<CacheHit<Entity>> getIfPresent(EntityType entityType, Object id)
-
getIfPresent
public Optional<CacheHit<Entity>> getIfPresent(EntityType entityType, Object id, @Nullable @CheckForNull Fetch fetch)
Retrieves an entity from the cache if present.- Parameters:
entityType- EntityType of the entity to retrieveid- id value of the entity to retrievefetch- containing attributes to retrieve, can be null- Returns:
- Optional
CacheHitwith the result from the cache, empty if no record of the entity is present in the cache
-
put
public void put(Entity entity)
Inserts an entity into the cache.- Parameters:
entity- the entity to insert into the cache
-
-