Class CacheEvictionsLogger
java.lang.Object
io.fluxzero.sdk.persisting.caching.CacheEvictionsLogger
- All Implemented Interfaces:
Consumer<CacheEviction>
Logs and publishes cache eviction events as metrics.
This class listens for eviction events from a Cache and forwards them to the configured
MetricsGateway. It is typically used to track cache performance and health over time,
especially in distributed or memory-sensitive applications.
To activate logging for a particular cache instance, call register(Cache).
This will subscribe the logger to that cache’s eviction stream.
Cache cache = ...;
CacheEvictionsLogger logger = new CacheEvictionsLogger(Fluxzero.get().metricsGateway());
logger.register(cache);
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(CacheEviction evictionEvent) Publishes the given cache eviction event to the configured metrics gateway.Registers this logger as an eviction listener for the givenCache.
-
Constructor Details
-
CacheEvictionsLogger
public CacheEvictionsLogger()
-
-
Method Details
-
register
Registers this logger as an eviction listener for the givenCache.Eviction events will be reported to the configured
MetricsGateway.- Parameters:
cache- The cache to monitor for evictions.- Returns:
- A
Registrationthat can be used to unsubscribe later.
-
accept
Publishes the given cache eviction event to the configured metrics gateway.- Specified by:
acceptin interfaceConsumer<CacheEviction>- Parameters:
evictionEvent- the event to report.
-