Class CredentialsCache

java.lang.Object
io.prometheus.jmx.common.http.authenticator.CredentialsCache

public class CredentialsCache extends Object
Class to implement a Credentials cache that is size constrained

The cache will purge old entries to make size for a cacheable credential

A credential that exceeds maximumCacheSizeBytes is not cached

  • Constructor Details

    • CredentialsCache

      public CredentialsCache(int maximumCacheSizeBytes)
      Constructor
      Parameters:
      maximumCacheSizeBytes - maximum cache size in bytes
  • Method Details

    • add

      public void add(Credentials credentials)
      Method to add a Credentials to the cache

      A credential that exceeds maximumCacheSizeBytes is not cached

      Parameters:
      credentials - credential
    • contains

      public boolean contains(Credentials credentials)
      Method to return whether the cache contains the Credentials
      Parameters:
      credentials - credentials
      Returns:
      true if the set contains the Credential, else false
    • remove

      public boolean remove(Credentials credentials)
      Method to remove a Credentials from the cache
      Parameters:
      credentials - credentials
      Returns:
      true if the Credentials existed and was removed, else false
    • getMaximumCacheSizeBytes

      Method to get the maximum cache size in bytes
      Returns:
      the maximum cache size in bytes
    • getCurrentCacheSizeBytes

      Method to get the current cache size in bytes
      Returns:
      the current cache size in bytes