• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ben-manes / caffeine / #2875
100%
master: 100%

Build:
Build:
LAST BUILD BRANCH: v3.dev
DEFAULT BRANCH: master
Ran 10 Apr 2022 07:43AM UTC
Jobs 1
Files 75
Run time 5s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
#2875

push

github-actions

ben-manes
Add Interner type for weakKey equality caching (fixes #344)

A weak keyed cache uses identity equivalence, as this is the only sensible
approach when caching a value. If Objects.equals was used then the user
would not be inclined to hold a reference to the canonical key and expect
any equivalent key to cause the mapping to be retained. As that is an
impossible expectation, the cache would seemingly discard prematurely.
Therefore we disallow this case to hint that users should be more thoughtful
about their desired behavior.

An interner is a Set-based cache where the key is the only item of interest.
This allows usages to resolve to a canonical instance, discard duplicates
as determined by Object.equals, and thereby reduce memory usage. A weak
interner allows the garbage collector to discard the canonical instance
when all usages have been reclaimed. This special case of a weak keyed
cache with Object.equals behavior is now supported, but hidden through
an interface to make the behavior explicit and avoid misuses.

For cases that want to cache by a canonical weak key to a value, the
two type should be used in conjunction. Instead of incorrectly trying
to combine into a single cache, use intern the key and use that for
the cache lookup.

6736 of 7107 relevant lines covered (94.78%)

0.95 hits per line

Jobs
ID Job ID Ran Files Coverage
1 #2875.1 10 Apr 2022 07:43AM UTC 0
94.78
Source Files on build #2875
Detailed source file information is not available for this build.
  • Back to Repo
  • Build #2875
  • c41bcd4b on github
  • Prev Build on v3.dev
  • Next Build on v3.dev
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc