Created
April 10, 2024 03:36
-
-
Save ensean/8b4f892270a75dc4a0200b7516a92410 to your computer and use it in GitHub Desktop.
node connect to memorydb for redis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Cluster } from "ioredis"; | |
const host = "clustercfg.test.xxxxxx.memorydb.ap-northeast-1.amazonaws.com"; | |
const port = 6379; | |
export const redis = new Cluster([{ host, port }], { | |
dnsLookup: (address, callback) => callback(null, address), | |
redisOptions: { | |
tls: {}, | |
}, | |
}); | |
await redis.set("abc", 1234) | |
var val = await redis.get("abc") | |
console.log(val) | |
Author
ensean
commented
Apr 10, 2024
- TLS 未开启时连接代码
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment