Class 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 Detail

      • 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 type
        entityId - id value of the entity to retrieve
        fetch - containing attributes to retrieve, can be null
        Returns:
        an Optional of which the CacheHit contains an Entity or 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.