

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# SecretCache
<a name="retrieving-secrets_cache-ref-secretcache"></a>

适用于从 Secrets Manager 检索的密钥的内存缓存。您使用 [get\$1secret\$1string](#retrieving-secrets_cache-ref-secretcache_get_secret_string) 或 [get\$1secret\$1binary](#retrieving-secrets_cache-ref-secretcache_get_secret_binary) 从缓存中检索密钥。您可以通过传入构造函数中的 [SecretCacheConfig](retrieving-secrets_cache-ref-secretcacheconfig.md) 对象来配置缓存设置。

有关包括示例在内的更多信息，请参阅 [使用 Python 和客户端缓存获取 Secrets Manager 密钥值](retrieving-secrets_cache-python.md)。

```
cache = SecretCache(
    config = SecretCacheConfig,
    client = [client](https://botocore.amazonaws.com/v1/documentation/api/latest/reference/services/secretsmanager.html)
)
```

**Topics**
+ [get\$1secret\$1string](#retrieving-secrets_cache-ref-secretcache_get_secret_string)
+ [get\$1secret\$1binary](#retrieving-secrets_cache-ref-secretcache_get_secret_binary)

## get\$1secret\$1string
<a name="retrieving-secrets_cache-ref-secretcache_get_secret_string"></a>

检索密钥字符串值。

请求语法  

```
response = cache.get_secret_string(
    secret_id='string',
    version_stage='string' )
```

参数  
+ `secret_id`（*字符串*）：[必需] 密钥的名称或 ARN。
+ `version_stage`（*字符串*）：您要检索的密钥的版本。有关更多信息，请参阅 [secret versions](whats-in-a-secret.md)。默认值为“AWSCURRENT”。

返回类型  
字符串

## get\$1secret\$1binary
<a name="retrieving-secrets_cache-ref-secretcache_get_secret_binary"></a>

检索密钥二进制值。

请求语法  

```
response = cache.get_secret_binary(
    secret_id='string',
    version_stage='string'
)
```

参数  
+ `secret_id`（*字符串*）：[必需] 密钥的名称或 ARN。
+ `version_stage`（*字符串*）：您要检索的密钥的版本。有关更多信息，请参阅 [secret versions](whats-in-a-secret.md)。默认值为“AWSCURRENT”。

返回类型  
[base64 编码的](https://tools.ietf.org/html/rfc4648#section-4)字符串