export { ZError } from './common/ZError.js'; export { SyncLocker } from './common/SyncLocker.js'; export { AsyncQueue, createAsyncQueue, createAsyncQueues } from './common/AsyncQueue.js'; import { RedisClient, ClientOpts } from 'redis'; /** * 单例化一个class * 使用方法: * @singleton * class Test {} * new Test() === new Test() // returns `true` * 也可以不使用 decorator * const TestSingleton = singleton(Test) * new TestSingleton() === new TestSingleton() //returns 'true' */ declare const SINGLETON_KEY: unique symbol; type Singleton any> = T & { [SINGLETON_KEY]: T extends new (...args: any[]) => infer I ? I : never; }; declare const singleton: any>(classTarget: T) => T; type Callback = (...args: any[]) => void; declare class ZRedisClient { pub: RedisClient; sub: RedisClient; protected subscribeAsync: any; protected unsubscribeAsync: any; protected publishAsync: any; protected subscriptions: { [channel: string]: Callback[]; }; protected smembersAsync: any; protected sismemberAsync: any; protected hgetAsync: any; protected hlenAsync: any; protected pubsubAsync: any; protected incrAsync: any; protected decrAsync: any; constructor(opts?: ClientOpts); subscribe(topic: string, callback: Callback): Promise; unsubscribe(topic: string, callback?: Callback): Promise; publish(topic: string, data: any): Promise; exists(roomId: string): Promise; setex(key: string, value: string, seconds: number): Promise; expire(key: string, seconds: number): Promise; get(key: string): Promise; set(key: string, val: string): Promise; del(roomId: string): Promise; sadd(key: string, value: any): Promise; smembers(key: string): Promise; sismember(key: string, field: string): Promise; srem(key: string, value: any): Promise; scard(key: string): Promise; srandmember(key: string): Promise; sinter(...keys: string[]): Promise; zadd(key: string, value: any, member: string): Promise; zincrby(key: string, value: any, member: string): Promise; zrangebyscore(key: string, min: number, max: number): Promise; zcard(key: string): Promise; zcount(key: string, min: number, max: number): Promise; zrevrank(key: string, member: string): Promise; zscore(key: string, member: string): Promise; zrevrange(key: string, start: number, end: number): Promise; hset(key: string, field: string, value: string): Promise; hincrby(key: string, field: string, value: number): Promise; hget(key: string, field: string): Promise; hgetall(key: string): Promise<{ [key: string]: string; }>; hdel(key: string, field: string): Promise; hlen(key: string): Promise; incr(key: string): Promise; decr(key: string): Promise; protected handleSubscription: (channel: string, message: string) => void; } export { SINGLETON_KEY, type Singleton, ZRedisClient, singleton };