https://github.com/dozyio/paramcache
SSM / AWS systems manager parameter store cache for Go Lambdas
https://github.com/dozyio/paramcache
go lambda lambda-functions ssm systems-manager
Last synced: about 2 months ago
JSON representation
SSM / AWS systems manager parameter store cache for Go Lambdas
- Host: GitHub
- URL: https://github.com/dozyio/paramcache
- Owner: dozyio
- License: mit
- Created: 2020-08-11T15:26:48.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-01-30T17:57:50.000Z (over 4 years ago)
- Last Synced: 2025-04-12T17:55:58.929Z (6 months ago)
- Topics: go, lambda, lambda-functions, ssm, systems-manager
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ParamCache - A Go SSM Parameter Store Cache
ParamCache is used in AWS Go Lambdas when cold booting to save repeated lookups on subsequent invocations.
Assumes SSM / AWS Systems Manager is in the same region as the lambda.Cache configurable via lambda environment variables:
SSM_CACHE_ENABLE string (default "TRUE")
SSM_CACHE_VERBOSE string (default "FALSE")
SSM_CACHE_TIMEOUT int (default 300 seconds)
# Usage
```go
import "github.com/dozyio/paramcache"...
tableName, err := paramcache.GetParameterStoreValue("dynamodb_table_name")
if err != nil {
//handle error
}
log.Printf("%s\n", *tableName.Parameter.Value)
```# Example: Cache timeout per parameter
It is possible to set a cache timeout value per parameter. The example below sets a 20 second cache for "dynamodb_table_name".
```go
tableName, err := paramcache.GetParameterStoreValue("dynamodb_table_name", 20)
```# Example: Don't cache a parameter
Setting a cache timeout of 0 will not add the parameter to the cache
```go
tableName, err := paramcache.GetParameterStoreValue("dynamodb_table_name", 0)
```