use of org.molgenis.data.Repository in project molgenis by molgenis.
the class L2Cache method get.
/**
* Retrieves an entity from the cache or the underlying repository.
*
* @param repository the underlying repository
* @param id the ID of the entity to retrieve
* @return the retrieved Entity, or null if the entity is not present.
* @throws com.google.common.util.concurrent.UncheckedExecutionException if the repository throws an error when
* loading the entity
*/
public Entity get(Repository<Entity> repository, Object id) {
LoadingCache<Object, Optional<Map<String, Object>>> cache = getEntityCache(repository);
EntityType entityType = repository.getEntityType();
return cache.getUnchecked(id).map(e -> entityHydration.hydrate(e, entityType)).orElse(null);
}
Aggregations