我尝试连接到elasticache来放置数据,但我还没有找到执行放置数据的方法。 如何在aws的elasticache resdis上输入和获取数据? 我的代码
mySession := getAWSSession()
svc := elasticache.New(mySession)
input := &elasticache.CreateCacheClusterInput{
AutoMinorVersionUpgrade: aws.Bool(true),
CacheClusterId: aws.String("my-redis"),
CacheNodeType: aws.String("cache.r3.larage"),
CacheSubnetGroupName: aws.String("default"),
Engine: aws.String("redis"),
EngineVersion: aws.String("3.2.4"),
NumCacheNodes: aws.Int64(1),
Port: aws.Int64(6379),
PreferredAvailabilityZone: aws.String("us-east-1c"),
SnapshotRetentionLimit: aws.Int64(7),
}
result, err := svc.CreateCacheCluster(input)
var data = Logo{}
data.name = "test1"
data.logo = "test2"
// how to put and get data from elasticache
答案 0 :(得分:8)
This您正在使用的SDK提供了用于管理ElastiCache基础架构的API,例如创建/删除群集或快照,添加标记,购买缓存节点等。它不提供API或在缓存中获取项目。
ElastiCache为您提供的Redis群集类似于您自己安装的群集。因此,您可以将其与AWS SDK外部的常用Go库连接。例如,go-redis/redis或garyburd/redigo。
简而言之,使用AWS SDK管理您的ElastiCache基础架构和Redis'去客户端放置或从缓存中获取项目。