Class L2CacheRepositoryDecorator

  • All Implemented Interfaces:
    Closeable, AutoCloseable, Iterable<org.molgenis.data.Entity>, org.molgenis.data.Repository<org.molgenis.data.Entity>

    public class L2CacheRepositoryDecorator
    extends org.molgenis.data.AbstractRepositoryDecorator<org.molgenis.data.Entity>
    Adds, removes and retrieves entities from the L2Cache when a Repository is RepositoryCapability.CACHEABLE.

    Delegates to the underlying repository when an action is not supported by the cache or when the cache doesn't contain the needed entity.

    • Constructor Summary

      Constructors 
      Constructor Description
      L2CacheRepositoryDecorator​(org.molgenis.data.Repository<org.molgenis.data.Entity> delegateRepository, L2Cache l2Cache, org.molgenis.data.transaction.TransactionInformation transactionInformation)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Stream<org.molgenis.data.Entity> findAll​(Stream<Object> ids)
      Retrieves multiple entities by id.
      Stream<org.molgenis.data.Entity> findAll​(Stream<Object> ids, org.molgenis.data.Fetch fetch)  
      org.molgenis.data.Entity findOneById​(Object id)
      Retrieves a single entity by id.
      org.molgenis.data.Entity findOneById​(Object id, org.molgenis.data.Fetch fetch)  
      • Methods inherited from class org.molgenis.data.AbstractRepositoryDecorator

        add, add, aggregate, close, count, count, delegate, delete, delete, deleteAll, deleteAll, deleteById, findAll, findOne, forEachBatched, getCapabilities, getEntityType, getName, getQueryOperators, iterator, query, update, update
      • Methods inherited from class com.google.common.collect.ForwardingObject

        toString
      • Methods inherited from interface org.molgenis.data.Repository

        forEachBatched, getExistingIDs, upsertBatch
    • Constructor Detail

      • L2CacheRepositoryDecorator

        public L2CacheRepositoryDecorator​(org.molgenis.data.Repository<org.molgenis.data.Entity> delegateRepository,
                                          L2Cache l2Cache,
                                          org.molgenis.data.transaction.TransactionInformation transactionInformation)
    • Method Detail

      • findOneById

        public org.molgenis.data.Entity findOneById​(Object id)
        Retrieves a single entity by id.
        Specified by:
        findOneById in interface org.molgenis.data.Repository<org.molgenis.data.Entity>
        Overrides:
        findOneById in class org.molgenis.data.AbstractRepositoryDecorator<org.molgenis.data.Entity>
        Parameters:
        id - the entity's ID value
        Returns:
        the retrieved Entity, or null if not present.
      • findAll

        public Stream<org.molgenis.data.Entity> findAll​(Stream<Object> ids)
        Retrieves multiple entities by id.

        If the repository is cacheable and the current transaction hasn't completely dirtied it, will split the stream into batches and load the batches through findAllBatch(List).

        Otherwise, will delegate this call to the decorated repository.

        Specified by:
        findAll in interface org.molgenis.data.Repository<org.molgenis.data.Entity>
        Overrides:
        findAll in class org.molgenis.data.AbstractRepositoryDecorator<org.molgenis.data.Entity>
        Parameters:
        ids - Stream of ids to retrieve
        Returns:
        Stream of retrieved Entitys, missing ones excluded
      • findAll

        public Stream<org.molgenis.data.Entity> findAll​(Stream<Object> ids,
                                                        org.molgenis.data.Fetch fetch)
        Specified by:
        findAll in interface org.molgenis.data.Repository<org.molgenis.data.Entity>
        Overrides:
        findAll in class org.molgenis.data.AbstractRepositoryDecorator<org.molgenis.data.Entity>
      • findOneById

        public org.molgenis.data.Entity findOneById​(Object id,
                                                    org.molgenis.data.Fetch fetch)
        Specified by:
        findOneById in interface org.molgenis.data.Repository<org.molgenis.data.Entity>
        Overrides:
        findOneById in class org.molgenis.data.AbstractRepositoryDecorator<org.molgenis.data.Entity>