Change your application: migrate from Amazon ElastiCache to KiviDB
The changes are the endpoint, the port, TLS, and the credentials. If the source was cluster-mode enabled, Serverless or MemoryDB and the target is a…
The changes are the endpoint, the port, TLS, and the credentials. If the source was cluster-mode enabled, Serverless or MemoryDB and the target is a non-sharded KiviDB, also switch from the cluster client to the plain one.
Python (redis-py)
# Before: ElastiCache cluster mode enabled, TLS, RBAC user
from redis.cluster import RedisCluster
r = RedisCluster(host="clustercfg.my-cluster.xxxxxx.use1.cache.amazonaws.com", port=6379,
ssl=True, username="app", password=os.environ["REDIS_PASSWORD"])
# After: KiviDB Cloud, TLS
import redis
r = redis.Redis(host="my-db.cloud.kividb.io", port=6380,
ssl=True, ssl_ca_certs="kividb-ca.pem",
username="kividbapp", password=os.environ["KIVIDB_PASSWORD"])
# After: a sharded KiviDB Cloud database
r = RedisCluster(host="my-db-s1.cloud.kividb.io", port=6380,
ssl=True, ssl_ca_certs="kividb-ca.pem",
username="kividbapp", password=os.environ["KIVIDB_PASSWORD"])
Node.js (ioredis)
// Before: ElastiCache cluster mode disabled, TLS, AUTH token
const redis = new Redis({
host: "master.my-cache.xxxxxx.use1.cache.amazonaws.com",
port: 6379,
password: process.env.REDIS_AUTH_TOKEN,
tls: {},
});
// After: KiviDB Cloud, TLS
const redis = new Redis({
host: "my-db.cloud.kividb.io",
port: 6380,
username: "kividbapp",
password: process.env.KIVIDB_PASSWORD,
tls: { ca: fs.readFileSync("kividb-ca.pem") },
});
Java (Lettuce)
// Before
RedisURI uri = RedisURI.builder()
.withHost("master.my-cache.xxxxxx.use1.cache.amazonaws.com").withPort(6379)
.withSsl(true).withAuthentication("app", password).build();
// After: trust the KiviDB CA through a truststore, or SslOptions.builder().trustManager(new File("kividb-ca.pem"))
RedisURI uri = RedisURI.builder()
.withHost("my-db.cloud.kividb.io").withPort(6380)
.withSsl(true).withAuthentication("kividbapp", kividbPassword).build();
As a URL: rediss://kividbapp:PASSWORD@my-db.cloud.kividb.io:6380.
Notes:
- The CA certificate. ElastiCache's certificates chain to a public authority, so clients often trust them with no setup. KiviDB Cloud's are issued by a private authority: download the CA from Configuration and give it to the client, as above. Connect by hostname, not IP address.
- Port. ElastiCache uses 6379 with and without TLS. KiviDB Cloud uses 6380
for TLS and 6379 for plain connections; a self-hosted KiviDB listens on 6380
unless you pass
--port, with TLS on whatever--tls-portyou choose. - IAM authentication. Remove the code that signs an IAM token and use the password.
- Reader endpoint. If you sent reads to the reader endpoint (or Serverless port 6380), a KiviDB Cloud Pro database has replicas for the same purpose; otherwise send everything to the primary.
- Hash tags (
{user:42}:cart) work the same in a sharded KiviDB, so keys that had to share a slot still do.