Skip to content

Releases: kasapdev/java-simple-cache

v1.3.0

Choose a tag to compare

@kasapdev kasapdev released this 20 Sep 08:01
69b8bea

Added

  • V remove(K key) - removes an entry and returns its live value (or null
    if absent/expired). Not counted as a hit or miss.
  • V computeIfAbsent(K key, Function<? super K, ? extends V> loader) and an
    overload taking an explicit long ttlMillis - returns the cached value or
    computes, stores and returns it. Runs under the cache lock, so concurrent
    callers for the same key run the loader once. Counts as one hit or miss. A
    null result or an exception stores nothing.
  • List<K> keys() - snapshot of live keys, least- to most-recently-used, with
    no effect on recency or statistics.

v1.2.0

Choose a tag to compare

@kasapdev kasapdev released this 07 Sep 20:03

Added

Cache hit/miss statistics on LruCache<K, V>:

  • long hitCount() - lifetime count of get() calls that found a live, non-expired entry.
  • long missCount() - lifetime count of get() calls that found nothing (key absent, or present but TTL-expired).
  • double hitRate() - hitCount / (hitCount + missCount) as a double; returns 0.0 before the first get() 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 ## Usage example (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 exact hitCount(), missCount(), and hitRate() values.

No breaking changes. All existing tests continue to pass unmodified.

v1.1.0

Choose a tag to compare

@kasapdev kasapdev released this 06 Sep 01:34

Adds edge-case regression tests: invalid capacity rejection, size() counting expired-but-unpurged entries per the documented contract, and re-putting an existing key not evicting others. No behavioral changes; all tests pass.

v1.0.0

Choose a tag to compare

@kasapdev kasapdev released this 05 Sep 23:41

Initial stable release.