Skip to main content
Version: 1.4.0

dynamodb

Cloud Databasebackend/dynamodb

Amazon DynamoDB is a fully managed NoSQL database service that provides fast and predictable performance with seamless scalability. It's designed for applications that need consistent, single-digit millisecond latency at any scale.

📦 Installation

go get github.com/azrod/kivigo/backend/dynamodb

Requires AWS credentials and a pre-created DynamoDB table. You can use AWS Free Tier which includes 25 GB of storage and 25 WCU/RCU.

Dependencies

  • AWS account with DynamoDB permissions
  • AWS credentials configured (IAM role, access key, or AWS CLI)
  • DynamoDB table created in your AWS region

✨ Features

Basic Operations
Batch Operations
Health Checks
Auto Scaling
Global Tables
Point-in-Time Recovery
On-Demand Billing
DAX Caching

🚀 Usage

package main

import (
"github.com/azrod/kivigo"
"github.com/azrod/kivigo/backend/dynamodb"
"github.com/aws/aws-sdk-go-v2/config"
)

func main() {
// Load AWS configuration
awsConfig, err := config.LoadDefaultConfig(context.TODO())
if err != nil {
panic(err)
}

// Basic configuration
opt := dynamodb.NewOptions()
opt.Config = awsConfig
opt.TableName = "kivigo-keyvalue"
opt.Region = "us-east-1"

// Optional: Custom configuration
opt.KeyAttribute = "id" // Primary key attribute name
opt.ValueAttribute = "data" // Value attribute name
opt.TTLAttribute = "expires" // TTL attribute name (optional)

// Optional: Configure read/write capacity for provisioned tables
opt.ReadCapacityUnits = 5
opt.WriteCapacityUnits = 5

// Create backend
kvStore, err := dynamodb.New(opt)
if err != nil {
panic(err)
}
defer kvStore.Close()

// Create client
client, err := kivigo.New(kvStore)
if err != nil {
panic(err)
}
}

📝 Notes

  • DynamoDB has a maximum item size of 400 KB
  • Batch operations can process up to 25 items (write) or 100 items (read) per request
  • Choose your partition key carefully to avoid hot partitions
  • Use on-demand billing for unpredictable workloads, provisioned for predictable ones
  • Global Secondary Indexes (GSI) allow querying on non-key attributes
  • DynamoDB Streams can trigger Lambda functions on data changes
  • Consider using DynamoDB Accelerator (DAX) for microsecond latency requirements
  • The free tier includes 25 GB storage, 25 WCU, and 25 RCU per month

🔗 Additional Resources