v1.2.0
Added
Cache hit/miss statistics on LruCache<K, V>:
long hitCount()- lifetime count ofget()calls that found a live, non-expired entry.long missCount()- lifetime count ofget()calls that found nothing (key absent, or present but TTL-expired).double hitRate()-hitCount / (hitCount + missCount)as adouble; returns0.0before the firstget()call to avoid dividing by zero.
Every call to get() updates these counters automatically - a hit for a live entry, a miss for an absent or expired one. Following Guava's CacheStats convention, the counters are cumulative for the life of the cache instance and are intentionally not reset by put() or clear() (documented in the class javadoc and the README).
Also adds:
- A "Cache Statistics" section to the README with a runnable example, and a second
## Usageexample (a lookup-cache pattern). - A hand-calculated regression test that walks a specific put/get sequence - including a capacity-triggered eviction and a post-
clear()get - and asserts exacthitCount(),missCount(), andhitRate()values.
No breaking changes. All existing tests continue to pass unmodified.