Reputation: 597106
I'm looking in the EhCache statistics, I see these figures:
CacheMisses: 75977
CacheHits: 38151InMemoryCacheMisses: 4843
InMemoryCacheHits: 38151
"memory" is the only store - no off-heap and no disk storage (overflowToDisk="false", diskPersistent="false"
). So what does these two mean? I would expect them to be the same (the hits are the same), but the misses differ greatly.
Upvotes: 7
Views: 1240
Reputation: 9110
Do you have some null
-valued Element
s in your cache? (Ehcache allows you to store Element
s with null
values, but I'm not sure if there's any constraints surrounding that).
Looking at the code for Cache.searchInStoreWithStats(Object key) in version 2.5.3, it seems that there is a bug there:
inMemoryMisses
uses a containsKey()
derivative, cacheMisses
null-checks against the result of a get()
derivative.So, each time you search for a key which exists in the InMemoryStore
but has a null
value, it will increment cacheMisses
but not inMemoryMisses
.
So, I might be completely off, but it smells right to me. What do you think?
Edit: I've realised my interpretation was wrong - the Element can't be null, (but its 'value' can be null). I'll leave this answer here anyway incase it triggers any other ideas
Upvotes: 1
Reputation: 333
I believe you are using ehcache 2.5+ . If you have cacheconfiguration with diskpersistance to true ( though overflowtodisk is false) , it writes to disk. So there could be diskhits as well? You can view them in the Statistics. do you have diskpersistance as true? Please post your cache configuration
Upvotes: 0