Teamlinker/code/server/common/cache/keys/base.ts
sx1989827 8909ffb076 add
2021-07-30 22:41:41 +08:00

23 lines
612 B
TypeScript

import { getRedisInstance, Redis } from "../redis";
class RedisBaseKey<T> {
protected redis:InstanceType<typeof Redis>=getRedisInstance()
protected type:T
protected name:string
constructor(name:string,type:T){
this.name=name,
this.type=type
}
}
export class RedisStringKey<T> extends RedisBaseKey<T> {
constructor(name:string,type:T){
super(name,type)
}
async get():Promise<T>{
let ret=await this.redis.get(this.name,this.type)
return ret
}
async set(value:T,ttl?:number){
await this.redis.set(this.name,value,ttl);
}
}