百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
A

aws-secretsmanager-caching-go

> 编程语言
开源

AWS Secrets Manager Go 缓存客户端可为 Go 应用程序实现进程内的秘密数据缓存。

100 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

AWS Secrets Manager Go 缓存客户端可为 Go 应用程序实现进程内的秘密数据缓存。

AWS Secrets Manager Go Caching Client

The AWS Secrets Manager Go caching client enables in-process caching of secrets for Go applications.

Getting Started

Required Prerequisites

To use this client you must have:

  • A Go development environment

    If you do not have one, go to Golang Getting Started on The Go Programming Language website, then download and install Go.

An Amazon Web Services (AWS) account to access secrets stored in AWS Secrets Manager and use AWS SDK for Go.

  • To create an AWS account, go to Sign In or Create an AWS Account and then choose I am a new user. Follow the instructions to create an AWS account.

  • To create a secret in AWS Secrets Manager, go to Creating Secrets and follow the instructions on that page.

Get Started

The following code sample demonstrates how to get started:

  1. Instantiate the caching client.
  2. Request secret.
go
// This example shows how an AWS Lambda function can be written
// to retrieve a cached secret from AWS Secrets Manager caching
// client.
package main

import (
	"github.com/aws/aws-lambda-go/lambda"
	"github.com/aws/aws-secretsmanager-caching-go/v2/secretcache"
)

var(
	secretCache, _ = secretcache.New()
)

func HandleRequest(secretId string) string {
	result, _ := secretCache.GetSecretString(secretId)
	// Use secret to connect to secured resource.
	return "Success"
}

func main() {
	lambda.Start(HandleRequest)
}

Cache Configuration

  • MaxCacheSize int The maximum number of cached secrets to maintain before evicting secrets that have not been accessed recently.
  • CacheItemTTL int64 The number of nanoseconds that a cached item is considered valid before requiring a refresh of the secret state. Items that have exceeded this TTL will be refreshed synchronously when requesting the secret value. If the synchronous refresh failed, the stale secret will be returned.
  • VersionStage string The version stage that will be used when requesting the secret values for this cache.
  • Hook CacheHook Used to hook in-memory cache updates.

Instantiating Cache with a custom Config and a custom Client

go

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

Getting Help

Please use these community resources for getting help:

  • Ask a question on Stack Overflow and tag it with aws-secrets-manager.
  • Open a support ticket with AWS Support
  • If it turns out that you may have found a bug, or have a feature request, please open an issue.

License

This library is licensed under the Apache 2.0 License.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Goaws-secrets-managercachinggolangsecret

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言