Karimila Babu Maganti
Karimila Babu Maganti

Reputation: 69

Spring @cachable - view cached data

One of my requirements requires to see how much data i have cached

I would like to see what data is cached in Spring.

Is there any way i can see what Spring cached? key and values

Upvotes: 6

Views: 13693

Answers (1)

Alan Hay
Alan Hay

Reputation: 23226

Well if you have a handle on the CacheManager

http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/cache/CacheManager.html

it has a method:

getCache(String name)

which returns a:

http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/cache/Cache.html

which has a method:

getNativeCache();

which you should then be able to query.

Upvotes: 8

Related Questions