Documentation ¶
Overview ¶
Package secretcache provides the Cache struct for in-memory caching of secrets stored in AWS Secrets Manager Also exports a CacheHook, for pre-store and post-fetch processing of cached values
Index ¶
- Constants
- type Cache
- func (c *Cache) GetSecretBinary(secretId string) ([]byte, error)
- func (c *Cache) GetSecretBinaryWithContext(ctx context.Context, secretId string) ([]byte, error)
- func (c *Cache) GetSecretBinaryWithStage(secretId string, versionStage string) ([]byte, error)
- func (c *Cache) GetSecretBinaryWithStageWithContext(ctx context.Context, secretId string, versionStage string) ([]byte, error)
- func (c *Cache) GetSecretString(secretId string) (string, error)
- func (c *Cache) GetSecretStringWithContext(ctx context.Context, secretId string) (string, error)
- func (c *Cache) GetSecretStringWithStage(secretId string, versionStage string) (string, error)
- func (c *Cache) GetSecretStringWithStageWithContext(ctx context.Context, secretId string, versionStage string) (string, error)
- func (c *Cache) RefreshNow(secretId string)
- func (c *Cache) RefreshNowWithContext(ctx context.Context, secretId string)
- type CacheConfig
- type CacheHook
- type InvalidConfigError
- type InvalidOperationError
- type VersionNotFoundError
Constants ¶
const ( DefaultMaxCacheSize = 1024 DefaultCacheItemTTL = 3600000000000 // 1 hour in nanoseconds DefaultVersionStage = "AWSCURRENT" )
const ( VersionNumber = "1" MajorRevisionNumber = "1" MinorRevisionNumber = "2" BugfixRevisionNumber = "0" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct { CacheConfig Client secretsmanageriface.SecretsManagerAPI // contains filtered or unexported fields }
Cache client for AWS Secrets Manager secrets.
func New ¶
New constructs a secret cache using functional options, uses defaults otherwise. Initialises a SecretsManager Client from a new session.Session. Initialises CacheConfig to default values. Initialises lru cache with a default max size.
func (*Cache) GetSecretBinary ¶
GetSecretBinary gets the secret binary value from the cache for given secret id and a default version stage. Returns the secret binary and an error if operation failed.
func (*Cache) GetSecretBinaryWithContext ¶ added in v1.1.1
func (*Cache) GetSecretBinaryWithStage ¶
GetSecretBinaryWithStage gets the secret binary value from the cache for given secret id and version stage. Returns the secret binary and an error if operation failed.
func (*Cache) GetSecretBinaryWithStageWithContext ¶ added in v1.1.1
func (*Cache) GetSecretString ¶
GetSecretString gets the secret string value from the cache for given secret id and a default version stage. Returns the secret string and an error if operation failed.
func (*Cache) GetSecretStringWithContext ¶ added in v1.1.1
func (*Cache) GetSecretStringWithStage ¶
GetSecretStringWithStage gets the secret string value from the cache for given secret id and version stage. Returns the secret string and an error if operation failed.
func (*Cache) GetSecretStringWithStageWithContext ¶ added in v1.1.1
func (*Cache) RefreshNow ¶ added in v1.2.0
Method to force the refresh of a secret inside the cache
type CacheConfig ¶
type CacheConfig struct { //The maximum number of cached secrets to maintain before evicting secrets that //have not been accessed recently. MaxCacheSize int //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. CacheItemTTL int64 //The version stage that will be used when requesting the secret values for //this cache. VersionStage string //Used to hook in-memory cache updates. Hook CacheHook }
CacheConfig is the config object passed to the Cache struct
type CacheHook ¶
type CacheHook interface { // Put prepares the object for storing in the cache. Put(data interface{}) interface{} // Get derives the object from the cached object. Get(data interface{}) interface{} }
CacheHook is an interface to hook into the local in-memory cache. This interface will allow users to perform actions on the items being stored in the in-memory cache. One example would be encrypting/decrypting items stored in the in-memory cache.
type InvalidConfigError ¶
type InvalidConfigError struct {
// contains filtered or unexported fields
}
func (*InvalidConfigError) Error ¶
func (i *InvalidConfigError) Error() string
type InvalidOperationError ¶
type InvalidOperationError struct {
// contains filtered or unexported fields
}
func (*InvalidOperationError) Error ¶
func (i *InvalidOperationError) Error() string
type VersionNotFoundError ¶
type VersionNotFoundError struct {
// contains filtered or unexported fields
}
func (*VersionNotFoundError) Error ¶
func (v *VersionNotFoundError) Error() string