0

I have a Spring Boot app with caching enabled using the @EnableCaching in the main class and @Cacheable for certain methods. This was earlier working well.

Now I have also configured GemFire cache to store other data.

The older code with the @Cacheable annotation is now trying to fetch this data in the GemFire cache. Is there a way to define when to use which cache?

I'm new to this and would appreciate any inputs on the best practice to be followed in such case and what can be done to overcome this.

Vaishnavi Killekar
  • 457
  • 1
  • 8
  • 22
  • 1
    There is no Spring Boot cache. Spring only provides an abstraction over different caching implementations, one of them being Gemfire. So it is nothing more than an abstraction. – M. Deinum Nov 12 '21 at 09:15
  • Okay, how do I fix this issue? The earlier cached data is not working correctly with `GemFire` – Vaishnavi Killekar Nov 12 '21 at 09:35
  • You can define multiple `CacheManager` instances (if you really want different cache implementatins) and use the `cacheManager` attribute on the `@Cacheable` to determine which one to use for that particulair cache.Or just only use Gemfire as your caching mechanism. – M. Deinum Nov 12 '21 at 09:37

1 Answers1

0

Have a look at this: https://docs.spring.io/spring-boot-data-geode-build/current/reference/html5/#geode-caching-provider, and specifically this: https://docs.spring.io/spring-boot-data-geode-build/current/reference/html5/#geode-caching-provider-disable.

If you are not using Spring Boot for Apache Geode (SBDG; see project home as well as the docs) (which also applies to VMware Tanzu GemFire as well, given GemFire is based on OSS, Apache Geode), then you most definitely should consider it.

If you need to control which cache is used for which, e.g. service method, then you should read more about custom cache resolution as opposed to the default cache resolution strategy.

Last, SBDG honors Spring Boot's Caching configuration, after SBDG is essentially Spring Boot specifically designed and developed for Apache Geode (and GemFire).

John Blum
  • 7,381
  • 1
  • 20
  • 30