Class CachedGauge<T>

java.lang.Object
io.dropwizard.metrics5.CachedGauge<T>
Type Parameters:
T - the type of the gauge's value
All Implemented Interfaces:
Gauge<T>, Metric

public abstract class CachedGauge<T> extends Object implements Gauge<T>
A Gauge implementation which caches its value for a period of time.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    CachedGauge(long timeout, TimeUnit timeoutUnit)
    Creates a new cached gauge with the given timeout period.
    protected
    CachedGauge(Clock clock, long timeout, TimeUnit timeoutUnit)
    Creates a new cached gauge with the given clock and timeout period.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the metric's current value.
    protected abstract T
    Loads the value and returns it.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CachedGauge

      protected CachedGauge(long timeout, TimeUnit timeoutUnit)
      Creates a new cached gauge with the given timeout period.
      Parameters:
      timeout - the timeout
      timeoutUnit - the unit of timeout
    • CachedGauge

      protected CachedGauge(Clock clock, long timeout, TimeUnit timeoutUnit)
      Creates a new cached gauge with the given clock and timeout period.
      Parameters:
      clock - the clock used to calculate the timeout
      timeout - the timeout
      timeoutUnit - the unit of timeout
  • Method Details

    • loadValue

      protected abstract T loadValue()
      Loads the value and returns it.
      Returns:
      the new value
    • getValue

      public T getValue()
      Description copied from interface: Gauge
      Returns the metric's current value.
      Specified by:
      getValue in interface Gauge<T>
      Returns:
      the metric's current value