Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is StatsCounter solely intended for consumption by Cache implementors? #1780

Closed
benjaminp opened this issue Sep 19, 2024 · 1 comment
Closed

Comments

@benjaminp
Copy link

StatsCounter has this javadoc:

* Accumulates statistics during the operation of a {@link Cache} for presentation by
* {@link Cache#stats}. This is solely intended for consumption by {@code Cache} implementors.

I suppose the last sentence is slightly ambiguous, but to me, it means StatsCounter shouldn't be implemented or used by caffeine reverse dependencies. However, a supplier for StatsCounter may be passed to Caffeine.recordStats since 2a8c688, which means it is a public interface.

@ben-manes
Copy link
Owner

I suppose that could be reworded. It originates from Guava where it’s nested as an implementation detail. There a custom one wasn’t provided as Google scrapes stats by polling instead of pushing.

In this case it means it’s not a general purpose utility or meant for extension of additional statistics that an application might want. Those can be added externally to the cache, like a putCount. The native stats are the minimal common ones or those that are otherwise not obtainable, rather than an event callback hook for every permutation of an activity. Thus consumption is who’s utilizing it, rather than implementing the interface to give to the cache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants