

As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.

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

Um cache na memória para segredos solicitados no Secrets Manager. Você usa [GetSecretString](#retrieving-secrets_cache-go_cache_operations_GetCachedSecret) ou [GetSecretBinary](#retrieving-secrets_cache-go_cache_operations_GetSecretBinary) para recuperar um segredo do cache. 

O exemplo a seguir mostra como definir as configurações de cache.

```
// 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 },
)
```

Para obter mais informações, incluindo exemplos, consulte [Obter um segredo do Secrets Manager usando Go com armazenamento em cache no lado do cliente](retrieving-secrets_cache-go.md).

## Métodos
<a name="retrieving-secrets_cache-go_cache_operations"></a>

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

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

O New constrói um cache do segredo usando opções funcionais. Caso contrário, usa opções padrão. Inicializa um SecretsManager cliente a partir de uma nova sessão. Inicializa CacheConfig com os valores padrão. Inicializa o cache LRU com um tamanho máximo padrão.

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

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

GetSecretString obtém o valor da string secreta do cache para determinado ID secreto. Retorna a string do segredo e um erro caso a operação falhe.

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

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

GetSecretStringWithStage obtém o valor da string secreta do cache para determinado ID secreto e [estágio de versão](whats-in-a-secret.md#term_version). Retorna a string do segredo e um erro caso a operação falhe.

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

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

GetSecretBinary obtém o valor binário secreto do cache para determinado ID secreto. Caso a operação falhe, ele retorna o binário do segredo e um erro.

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

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

GetSecretBinaryWithStage obtém o valor binário secreto do cache para determinado ID secreto e [estágio de versão](whats-in-a-secret.md#term_version). Caso a operação falhe, ele retorna o binário do segredo e um erro. 