0

I need to refresh my Redis cache every time some insert/update happens in the DB through a flyway migration script. Is there any way to achieve this? My application is written in Spring Boot.

Shamil Puthukkot
  • 442
  • 2
  • 17

1 Answers1

0

You can use help of cacheManager.

public void clearCache() {
    cacheManager.getCacheNames()
                .parallelStream()
                .forEach(n -> cacheManager.getCache(n).clear());
}

Also check for documentation.

RedisCacheManagerBuilder

  • How do i trigger this when a flyway migration occur? I am looking for a way to connect migration script execution and cache clear method – Shamil Puthukkot Sep 27 '22 at 02:12