cacheAndRefreshWhenNeeded method
Pass as tearoff to an "aws_xxx_api" constructor. Example:
final ddb = DynamoDB(
region: 'eu-west-1',
credentialsProvider: CachedCredentialProvider(fromIni).cacheAndRefreshWhenNeeded,
);
Implementation
Future<AwsClientCredentials?> cacheAndRefreshWhenNeeded({
Client? client,
}) async {
final expiration = previousCreds?.expiration;
if (previousCreds == null ||
expiration != null && DateTime.now().isAfter(expiration)) {
previousCreds = await credentialsProvider(client: client);
}
return previousCreds;
}