Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

177
Vistas
Spring Boot Start Cache Not triggering

I am running a spring boot 1.5.2 app. I wanted to add caching to my service methods I have added the spring-boot-starter-cache maven dependency and I am using the @ Cacheable annotations but it is not taking effect I created my service beans in a @ Configuration class - here is an example

@Bean(name = "policyService")
public IPolicyService policyService() {
    policyService = new PolicyServiceImpl();
    return policyService;
}

Here is an example of my service method

@Cacheable(value="policiesCache")
    public List<PolicyDBO> findAllPolicies() {
        LOG.info("Entered findAllPolicies");

        List<PolicyDBO> policyList = policyRespoitory.findAll();

        LOG.info("Exiting findAllPolicies");
        return policyList;
    }

My repoistory interface method is as follows

@Repository
public interface PolicyRepository extends CrudRepository<PolicyDBO, Long>{

    /** Find policy by id **/
    PolicyDBO findById(Long policyId);
}

Whenever I call this service method from a RestController - the caching is never triggered - it looks like it is not setup properly

Any ideas what I can do to get caching setup correctly?

Thanks Damien

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Assuming that caching is active, Spring Caching is working correctly, but not as you expect. @Cacheable caches arguments against results.

In your case, the cache is storing no arguments against the result of List<PolicyDBO>.

However when you call findById, the cache doesn't find anything against an argument of Long and so doesn't return a cached result.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda