You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
545 B
TypeScript

import Redis from 'ioredis'
const clients = new Map<string,RedisClientDriver>()
export class RedisClientDriver extends Redis {
constructor (
/**
* redis 客户端名字
*/
private readonly _name:string,
host:string,
port:number,
password:string,
db:number
) {
super(port,host,{
password,
db
})
clients.set(this.name,this)
}
static getClient (name:string):RedisClientDriver|null {
return clients.get(name) || null
}
get name ():string {
return this._name
}
}