@blued-core-oversea/ioredis-client
v0.2.0
Published
基于 ioredis 的一层封装。
Downloads
16
Readme
基于 ioredis 的一层封装。
npm i @blued-core-oversea/ioredis-client
redis client:
export const redis: Record<string, string | RedisClientConf> = {
test: 'xxxxxxxxxxxxx',
}
// or
export const redis: Record<string, string | RedisClientConf> = {
test: {
host: 'xxxxxxxxxxxxx',
maxConnAge: 5 * 1000,
poolSize: 3,
verify: { // 用户名密码【非必须项】
userNameConf: 'xxxxxxxxxxx',
passwordConf: 'xxxxxxxxxxx',
}
},
test2: 'xxxxxxxxxxxxxx',
}
const redisClient = new RedisClient(redis, {
commandTimeout: 100,
maxRetry: 2000,
enableReadyCheck: false,
})
const testRedisClient = () => redisClient.getClient('test')
async function main () {
const test = await awsRedisClient().pipeline().type('test').type('aaaaaaaa')
.exec()
console.log(test)
}
main()
cluster redis client:
export const redis = {
test: 'xxxxxxxxxxxxx',
}
const redisClient = new ClusterRedisClient(redis, {
isPingCheck: true,
refreshDuration: 2,
})
const testRedisClient = () => redisClient.getClient('test')
async function main () {
await testRedisClient().get('a')
}
main()