简体   繁体   中英

Cache Evict Verification

I use Redis as a cache store in spring boot using @Cachable annotation and evict it programitically using:

cacheManager.getCache(cacheName).clear()

The eviction process works fine. I need to add additional check after eviction that if cache entries still exist, and then perform some alert operation. For that, I need to get the Cache, check # of entries etc. I am trying the following way, but unable to retrieve anything:

cacheManager.getCache(cacheName).getNativeCache()

Is there any way to check if that Cache (Redis Cache) is a valid Cache and can contain keys/values.

cacheManager.getCacheNames()

This returns all the caches present at the moment. You can check if your evicted cache is present anymore or not and then perform alert operation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM