Cache invalidation in Ehcache

后端 未结 5 1396
北恋
北恋 2020-12-19 09:03

I am using Ehcache in Hibernate.

How can I notify the cache that the database has changed? How can I invalidate the cached data? How can I programmatically achieve t

5条回答
  •  太阳男子
    2020-12-19 09:50

    In case if you want to remove a specific cache (eg:employeeCache)

    @Autowired
    CacheManager cacheManager;
    

    place where you want to invalidate cache, use below code

        Cache cache = cacheManager.getCache("employeeCache");
        cache.removeAll();
    

提交回复
热议问题