@Test void evict() { String entityTypeId = "MyEntityTypeId"; EntityType entityType = when(mock(EntityType.class).getId()).thenReturn(entityTypeId).getMock(); Object entityId = mock(Object.class); Entity entity = when(mock(Entity.class).getIdValue()).thenReturn(entityId).getMock(); when(entity.getEntityType()).thenReturn(entityType); l1Cache.put(entity); l1Cache.evict(entity); assertEquals(Optional.empty(), l1Cache.get(entityType, entityId)); }
void evict(Entity entity) { CombinedEntityCache entityCache = caches.get(); if (entityCache != null) { entityCache.evict( Stream.of(EntityKey.create(entity.getEntityType().getId(), entity.getIdValue()))); } }
L1Cache implements TransactionListener { void evict(Entity entity) { CombinedEntityCache entityCache = caches.get(); if (entityCache != null) { entityCache.evict( Stream.of(EntityKey.create(entity.getEntityType().getId(), entity.getIdValue()))); } } }
L1Cache implements TransactionListener { void evict(Entity entity) { CombinedEntityCache entityCache = caches.get(); if (entityCache != null) { entityCache.evict( Stream.of(EntityKey.create(entity.getEntityType().getId(), entity.getIdValue()))); } } L1Cache(TransactionManager transactionManager, EntityHydration entityHydration); }
L1Cache implements TransactionListener { void evict(Entity entity) { CombinedEntityCache entityCache = caches.get(); if (entityCache != null) { entityCache.evict( Stream.of(EntityKey.create(entity.getEntityType().getId(), entity.getIdValue()))); } } L1Cache(TransactionManager transactionManager, EntityHydration entityHydration); @Override void transactionStarted(String transactionId); @Override void doCleanupAfterCompletion(String transactionId); Optional<CacheHit<Entity>> get(EntityType entityType, Object entityId); Optional<CacheHit<Entity>> get(
      EntityType entityType, Object entityId, @Nullable @CheckForNull Fetch fetch); void put(Entity entity); }
L1Cache implements TransactionListener { void evict(Entity entity) { CombinedEntityCache entityCache = caches.get(); if (entityCache != null) { entityCache.evict( Stream.of(EntityKey.create(entity.getEntityType().getId(), entity.getIdValue()))); } } L1Cache(TransactionManager transactionManager, EntityHydration entityHydration); @Override void transactionStarted(String transactionId); @Override void doCleanupAfterCompletion(String transactionId); Optional<CacheHit<Entity>> get(EntityType entityType, Object entityId); Optional<CacheHit<Entity>> get(
      EntityType entityType, Object entityId, @Nullable @CheckForNull Fetch fetch); void put(Entity entity);  }