Documentation
¶
Overview ¶
Package dynamocache provides a DynamoDB-backed cache.Store implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New builds a DynamoDB-backed cachecore.Store.
Defaults: - Region: "us-east-1" when empty - Table: "cache_entries" when empty - DefaultTTL: 5*time.Minute when zero - Prefix: "app" when empty - Client: auto-created when nil (uses Region and optional Endpoint) - Endpoint: empty by default (normal AWS endpoint resolution)
Example: custom dynamo table via explicit driver config
ctx := context.Background()
store, err := dynamocache.New(ctx, dynamocache.Config{
BaseConfig: cachecore.BaseConfig{
DefaultTTL: 5 * time.Minute,
Prefix: "app",
},
Region: "us-east-1",
Table: "cache_entries",
})
if err != nil {
panic(err)
}
fmt.Println(store.Driver()) // dynamo
Types ¶
type Config ¶
type Config struct {
cachecore.BaseConfig
Client DynamoAPI
Endpoint string
Region string
Table string
}
Config configures a DynamoDB-backed cache store.
type DynamoAPI ¶
type DynamoAPI interface {
GetItem(ctx context.Context, params *dynamodb.GetItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.GetItemOutput, error)
PutItem(ctx context.Context, params *dynamodb.PutItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error)
DeleteItem(ctx context.Context, params *dynamodb.DeleteItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.DeleteItemOutput, error)
BatchWriteItem(ctx context.Context, params *dynamodb.BatchWriteItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.BatchWriteItemOutput, error)
Scan(ctx context.Context, params *dynamodb.ScanInput, optFns ...func(*dynamodb.Options)) (*dynamodb.ScanOutput, error)
CreateTable(ctx context.Context, params *dynamodb.CreateTableInput, optFns ...func(*dynamodb.Options)) (*dynamodb.CreateTableOutput, error)
DescribeTable(ctx context.Context, params *dynamodb.DescribeTableInput, optFns ...func(*dynamodb.Options)) (*dynamodb.DescribeTableOutput, error)
}
DynamoAPI captures the subset of DynamoDB client methods used by the store.
Click to show internal directories.
Click to hide internal directories.