

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# type Cache
<a name="retrieving-secrets_cache-go_cache"></a>

Secrets Manager からリクエストされたシークレットのインメモリキャッシュ。[GetSecretString](#retrieving-secrets_cache-go_cache_operations_GetCachedSecret) または [GetSecretBinary](#retrieving-secrets_cache-go_cache_operations_GetSecretBinary) を使用して、キャッシュからシークレットを取得します。

次に、キャッシュの設定方法の例を示します。

```
// Create a custom secretsmanager client
client := getCustomClient()

// Create a custom CacheConfig struct 
config := secretcache. CacheConfig{
    MaxCacheSize:  secretcache.DefaultMaxCacheSize + 10,
    VersionStage:  secretcache.DefaultVersionStage,
    CacheItemTTL:  secretcache.DefaultCacheItemTTL,
}
	
// Instantiate the cache 
cache, _ := secretcache.New(
    func( c *secretcache.Cache) {  c. CacheConfig = config },
    func( c *secretcache.Cache) {  c. Client = client },
)
```

詳細と例については、「[Go とクライアント側のキャッシュを使用して、Secrets Manager のシークレット値を取得する](retrieving-secrets_cache-go.md)」を参照してください。

## 方法
<a name="retrieving-secrets_cache-go_cache_operations"></a>

### 新
<a name="retrieving-secrets_cache-go_cache_operations_New"></a>

`func New(optFns ...func(*Cache)) (*Cache, error)`

New は機能オプションを使用してシークレットキャッシュを構築します。それ以外の場合はデフォルトが使用されます。新しいセッションから Secrets Manager クライアントを初期化します。CacheConfig をデフォルト値に初期化します。LRU キャッシュをデフォルトの最大サイズで初期化します。

### GetSecretString
<a name="retrieving-secrets_cache-go_cache_operations_GetCachedSecret"></a>

`func (c *Cache) GetSecretString(secretId string) (string, error)`

GetSecretString は、指定されたシークレット ID のキャッシュからシークレット文字列値を取得します。シークレット文字列を返し、オペレーションが失敗した場合はエラーを返します。

### GetSecretStringWithStage
<a name="retrieving-secrets_cache-go_cache_operations_GetSecretStringWithStage"></a>

`func (c *Cache) GetSecretStringWithStage(secretId string, versionStage string) (string, error)`

GetSecretStringWithStage は、指定されたシークレット ID と[バージョンステージ](whats-in-a-secret.md#term_version)のキャッシュからシークレット文字列値を取得します。シークレット文字列を返し、オペレーションが失敗した場合はエラーを返します。

### GetSecretBinary
<a name="retrieving-secrets_cache-go_cache_operations_GetSecretBinary"></a>

`func (c *Cache) GetSecretBinary(secretId string) ([]byte, error) {`

GetSecretBinary は、指定されたシークレット ID のキャッシュからシークレットバイナリ値を取得します。シークレットバイナリを返し、オペレーションが失敗した場合はエラーを返します。

### GetSecretBinaryWithStage
<a name="retrieving-secrets_cache-go_cache_operations_GetSecretBinaryWithStage"></a>

`func (c *Cache) GetSecretBinaryWithStage(secretId string, versionStage string) ([]byte, error)`

GetSecretBinaryWithStage は、指定されたシークレット ID と[バージョンステージ](whats-in-a-secret.md#term_version)のキャッシュからシークレットバイナリ値を取得します。シークレットバイナリを返し、オペレーションが失敗した場合はエラーを返します。