Class SecretCacheConfiguration

java.lang.Object
com.amazonaws.secretsmanager.caching.SecretCacheConfiguration

public class SecretCacheConfiguration extends Object
Cache configuration options such as max cache size, ttl for cached items, etc.
  • Field Details

    • DEFAULT_MAX_CACHE_SIZE

      public static final int DEFAULT_MAX_CACHE_SIZE
      The default cache size.
      See Also:
    • DEFAULT_CACHE_ITEM_TTL

      public static final long DEFAULT_CACHE_ITEM_TTL
      The default TTL for an item stored in cache before access causing a refresh.
    • DEFAULT_VERSION_STAGE

      public static final String DEFAULT_VERSION_STAGE
      The default version stage to use when retrieving secret values.
      See Also:
    • DEFAULT_FORCE_REFRESH_JITTER

      public static final long DEFAULT_FORCE_REFRESH_JITTER
      The default maximum jitter value in milliseconds to use when forcing a refresh. This prevents continuous refreshNow() calls by adding a random sleep.
      See Also:
  • Constructor Details

    • SecretCacheConfiguration

      public SecretCacheConfiguration()
      Default constructor for the SecretCacheConfiguration object.
  • Method Details

    • getClient

      public software.amazon.awssdk.services.secretsmanager.SecretsManagerClient getClient()
      Returns the AWS Secrets Manager client that is used for requesting secret values.
      Returns:
      The AWS Secrets Manager client.
    • setClient

      public void setClient(software.amazon.awssdk.services.secretsmanager.SecretsManagerClient client)
      Sets the AWS Secrets Manager client that should be used by the cache for requesting secrets.
      Parameters:
      client - The AWS Secrets Manager client.
    • withClient

      public SecretCacheConfiguration withClient(software.amazon.awssdk.services.secretsmanager.SecretsManagerClient client)
      Sets the AWS Secrets Manager client that should be used by the cache for requesting secrets.
      Parameters:
      client - The AWS Secrets Manager client.
      Returns:
      The updated ClientConfiguration object with the new client setting.
    • getCacheHook

      public SecretCacheHook getCacheHook()
      Returns the interface used to hook in-memory cache updates.
      Returns:
      The object used to hook in-memory cache updates.
    • setCacheHook

      public void setCacheHook(SecretCacheHook cacheHook)
      Sets the interface used to hook the in-memory cache.
      Parameters:
      cacheHook - The interface used to hook the in-memory cache.
    • withCacheHook

      public SecretCacheConfiguration withCacheHook(SecretCacheHook cacheHook)
      Sets the interface used to hook the in-memory cache.
      Parameters:
      cacheHook - The interface used to hook in-memory cache.
      Returns:
      The updated ClientConfiguration object with the new setting.
    • getMaxCacheSize

      public int getMaxCacheSize()
      Returns the max cache size that should be used for creating the cache.
      Returns:
      The max cache size.
    • setMaxCacheSize

      public void setMaxCacheSize(int maxCacheSize)
      Sets the max cache size.
      Parameters:
      maxCacheSize - The max cache size.
    • withMaxCacheSize

      public SecretCacheConfiguration withMaxCacheSize(int maxCacheSize)
      Sets the max cache size.
      Parameters:
      maxCacheSize - The max cache size.
      Returns:
      The updated ClientConfiguration object with the new max setting.
    • getCacheItemTTL

      public long getCacheItemTTL()
      Returns the TTL for the cached items.
      Returns:
      The TTL in milliseconds before refreshing cached items.
    • setCacheItemTTL

      public void setCacheItemTTL(long cacheItemTTL)
      Sets the TTL in milliseconds for the cached items. Once cached items exceed this TTL, the item will be refreshed using the AWS Secrets Manager client.
      Parameters:
      cacheItemTTL - The TTL for cached items before requiring a refresh.
    • withCacheItemTTL

      public SecretCacheConfiguration withCacheItemTTL(long cacheItemTTL)
      Sets the TTL in milliseconds for the cached items. Once cached items exceed this TTL, the item will be refreshed using the AWS Secrets Manager client.
      Parameters:
      cacheItemTTL - The TTL for cached items before requiring a refresh.
      Returns:
      The updated ClientConfiguration object with the new TTL setting.
    • getVersionStage

      public String getVersionStage()
      Returns the version stage that is used for requesting secret values.
      Returns:
      The version stage used in requesting secret values.
    • setVersionStage

      public void setVersionStage(String versionStage)
      Sets the version stage that should be used for requesting secret values from AWS Secrets Manager
      Parameters:
      versionStage - The version stage used for requesting secret values.
    • withVersionStage

      public SecretCacheConfiguration withVersionStage(String versionStage)
      Sets the version stage that should be used for requesting secret values from AWS Secrets Manager
      Parameters:
      versionStage - The version stage used for requesting secret values.
      Returns:
      The updated ClientConfiguration object with the new version stage setting.
    • getForceRefreshJitterMillis

      public long getForceRefreshJitterMillis()
      Returns the refresh jitter that is used when force refreshing secrets.
      Returns:
      The maximum jitter sleep time in milliseconds used with refreshing secrets.
    • setForceRefreshJitterMillis

      public void setForceRefreshJitterMillis(long forceRefreshJitterMillis)
      Sets the maximum sleep time in milliseconds between force refresh calls. This value is used to prevent continuous refreshNow() calls in tight loops by adding a random sleep between half the configured value and the full value. The value must be greater than or equal to zero.
      Parameters:
      forceRefreshJitterMillis - The maximum sleep time in milliseconds between force refresh calls.
      Throws:
      IllegalArgumentException - if the value is negative
    • withForceRefreshJitterMillis

      public SecretCacheConfiguration withForceRefreshJitterMillis(long forceRefreshJitterMillis)
      Sets the maximum sleep time in milliseconds between force refresh calls. This value is used to prevent continuous refreshNow() calls in tight loops by adding a random sleep between half the configured value and the full value.
      Parameters:
      forceRefreshJitterMillis - The maximum sleep time in milliseconds between force refresh calls.
      Returns:
      The updated ClientConfiguration object with the new refresh sleep time.
      Throws:
      IllegalArgumentException - if the value is negative