UNPKG

@litert/redis

Version:

A redis protocol implement for Node.js.

68 lines 2.6 kB
/** * Copyright 2025 Angus.Fenying <fenying@litert.org> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import * as C from './Common'; import { EventEmitter } from 'node:events'; import * as $Net from 'node:net'; export declare class ProtocolClient extends EventEmitter implements C.IProtocolClient { protected readonly _cfg: C.IProtocolClientOptions; protected _aclUser: string; protected _passwd: string; protected _db: number; private _ready; private _executingQueue; private readonly _decoder; private readonly _encoder; get host(): string; get port(): number; private _socket; private _promise4Socket?; constructor(opts: C.IProtocolClientOptions); /** * Use an existing socket or create a new one. */ protected _getConnection(): Promise<$Net.Socket>; private _redisConnect; auth(password: string, username?: string): Promise<void>; select(db: number): Promise<void>; /** * Create a network socket and make it connect to the server. * * @param {string} host The host of server. * @param {number} port The port of server. * @param {number} timeout The timeout for the connecting to server. * @returns {Promise<$Net.Socket>} */ private _netConnect; connect(cb?: C.ICallbackA<void>): any; close(cb?: C.ICallbackA<void>): any; /** * Make async process same in both callback and promise styles. * @param fn The body of async process * @param cb The optional callback function if not promise style. * @returns Return a promise if cb is not provided. */ private _unifyAsync; command(cmd: string, args: any[], cb?: C.ICallbackA): any; protected _checkQueueSize(): void; protected _command(cmd: string, args: any[], cb?: C.ICallbackA): any; protected _bulkCommands(cmdList: Array<{ cmd: string; args: any[]; }>, cb?: C.ICallbackA): any; protected _commitExec(qty: number): Promise<any>; private _setTimeoutForRequest; } //# sourceMappingURL=ProtocolClient.d.ts.map