This small piece of code demonstrates how AWS ElastiCache can be used for Redis in Golang applications.


// Connecting to an AWS Elasticache Redis instance.
var tlsConfig *tls.Config
if env != "local" {
tlsConfig = &tls.Config{
MinVersion: tls.VersionTLS12,
}
}

client := redis.New(goredis.NewClient(&goredis.Options{
Addr: "primary-cache-001.inanzzz-cache.abcdef.use2.cache.amazonaws.com:6379",
Password: "a-secret-pass-token",
DB: 0,
PoolSize: 1,
TLSConfig: tlsConfig,
}))

// Client is ready for use.
client...