java - See cache's hit and misses -
i using hibernate , ehcache second level cache enabled. put @cacheable on user entity, this:
@cacheable @cache(usage = cacheconcurrencystrategy.nonstrict_read_write, region = "userscache") public class user extends abstractentity { ... }
but when enable hibernate's sql logging, still see `select * users userid = ?" query... thought maybe normal behavior , cache process somehow transparent hibernate, querying , ehcache intercepts , gets data cache... how can see whether query hit or miss?
you can enable hibernate statistics generation setting hibernate.generate_statistics property true
. can monitor cache hit/miss count via sessionfactory.getstatistics()
.
sessionfactory.getstatistics().getsecondlevelcachestatistics()
provides information.
also can seen through jconsole
, refer this.
Comments
Post a Comment