Class SecretCache
java.lang.Object
com.amazonaws.secretsmanager.caching.SecretCache
- All Implemented Interfaces:
AutoCloseable
Provides the primary entry-point to the AWS Secrets Manager client cache SDK.
Most people will want to use either
getSecretString(String) or
getSecretBinary(String) to retrieve a secret from the cache.
The core concepts (and classes) in this SDK are:
SecretCache provides an in-memory cache for secrets requested from
AWS Secrets Manager.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new secret cache using the standard AWS Secrets Manager client with default options.SecretCache(SecretCacheConfiguration config) Constructs a new secret cache using the provided cache configuration.SecretCache(software.amazon.awssdk.services.secretsmanager.SecretsManagerClient client) Constructs a new secret cache using the provided AWS Secrets Manager client.SecretCache(software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder builder) Constructs a new secret cache using an AWS Secrets Manager client created using the provided builder. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Method to close the cache.getSecretBinary(String secretId) Method to retrieve a binary secret from AWS Secrets Manager.getSecretString(String secretId) Method to retrieve a string secret from AWS Secrets Manager.booleanrefreshNow(String secretId) Method to force the refresh of a cached secret state.
-
Constructor Details
-
SecretCache
public SecretCache()Constructs a new secret cache using the standard AWS Secrets Manager client with default options. -
SecretCache
public SecretCache(software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder builder) Constructs a new secret cache using an AWS Secrets Manager client created using the provided builder.- Parameters:
builder- The builder to use for creating the AWS Secrets Manager client.
-
SecretCache
public SecretCache(software.amazon.awssdk.services.secretsmanager.SecretsManagerClient client) Constructs a new secret cache using the provided AWS Secrets Manager client.- Parameters:
client- The AWS Secrets Manager client to use for requesting secret values.
-
SecretCache
Constructs a new secret cache using the provided cache configuration.- Parameters:
config- The secret cache configuration.
-
-
Method Details
-
getSecretString
Method to retrieve a string secret from AWS Secrets Manager.- Parameters:
secretId- The identifier for the secret being requested.- Returns:
- The string secret
-
getSecretBinary
Method to retrieve a binary secret from AWS Secrets Manager.- Parameters:
secretId- The identifier for the secret being requested.- Returns:
- The binary secret
-
refreshNow
Method to force the refresh of a cached secret state.- Parameters:
secretId- The identifier for the secret being refreshed.- Returns:
- True if the refresh completed without error.
- Throws:
InterruptedException- If the thread is interrupted while waiting for the refresh.
-
close
public void close()Method to close the cache.- Specified by:
closein interfaceAutoCloseable
-