Class L2Cache

    • Method Detail

      • get

        public Entity get​(Repository<Entity> repository,
                          Object id)
        Retrieves an entity from the cache or the underlying repository.
        Parameters:
        repository - the underlying repository
        id - the ID of the entity to retrieve
        Returns:
        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
      • get

        public Entity get​(Repository<Entity> repository,
                          Object id,
                          Fetch fetch)
        Retrieves a partial entity from the cache or the underlying repository.
        Parameters:
        repository - the underlying repository
        id - the ID of the entity to retrieve
        fetch - containing attributes to retrieve, can be null
        Returns:
        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
      • getBatch

        public List<Entity> getBatch​(Repository<Entity> repository,
                                     Iterable<Object> ids)
        Retrieves a list of entities from the cache. If the cache doesn't yet exist, will create the cache.
        Parameters:
        repository - the underlying repository, used to create the cache loader or to retrieve the existing cache
        ids - Iterable of the ids of the entities to retrieve
        Returns:
        List containing the retrieved entities, missing values are excluded
        Throws:
        RuntimeException - if the cache failed to load the entities
      • getBatch

        public List<Entity> getBatch​(Repository<Entity> repository,
                                     Iterable<Object> ids,
                                     Fetch fetch)
        Retrieves a list of partial entities from the cache. If the cache doesn't yet exist, will create the cache.
        Parameters:
        repository - the underlying repository, used to create the cache loader or to retrieve the existing cache
        ids - Iterable of the ids of the entities to retrieve
        fetch - containing attributes to retrieve, can be null
        Returns:
        List containing the retrieved entities, missing values are excluded
        Throws:
        RuntimeException - if the cache failed to load the entities
      • logStatistics

        @Scheduled(fixedRate=60000L)
        public void logStatistics()
        Logs cumulative cache statistics for all known caches.