node 连接 redis
官方文档:Node Redis
github:Github
npm i ioredis
1
基本使用
ts
import Redis from "ioredis";
const client = new Redis({
host: '10.10.10.10',
port: 6379,
username: 'default',
password: 'password'
})
client.get('a').then(res => {
console.log(res)
}).catch(e => {
console.log(e)
})
client.del('a').then(res=>{
console.log(res)
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
其他
后续再补充,基本跟在客户端使用一致