UNPKG

memcached-node

Version:
71 lines (70 loc) 2.83 kB
/// <reference types="node" /> import { EventEmitter } from "events"; import { Response, StatsResponse } from "./response"; import { ServerConfigs } from "./server"; export declare enum Status { INIT = "INIT", CONNECTING = "CONNECTING", IDLE = "IDLE", RESEARVED = "RESEARVED", CLOSE = "CLOSE" } export interface ConnectionOptions { mode: modes; timeout: number; removeDeadServer: boolean; retry: boolean; retryLimit: number; exponentialBackoff: boolean; } export declare type ConnectionConfig = string | Array<string> | ServerConfigs; export declare const defaultConnectionOptions: Partial<ConnectionOptions>; declare type modes = "string" | "json"; export interface StoreOptions { isCompressed?: boolean; expires?: number; mode?: modes; } export interface RetrieveOptions { mode?: modes; } export declare class Connection extends EventEmitter { status: Status; id: number; private _servers; private _sockets; private _queue; private _hashring; private _options; constructor(args: ConnectionConfig, id?: number, options?: Partial<ConnectionOptions>); connect(status?: Status): Promise<void>; join(args: ConnectionConfig): void; close(force?: boolean): void; isReady(): boolean; isIdle(): boolean; get(keys: string | Array<string>, options?: RetrieveOptions): Promise<Response>; gets(keys: string | Array<string>, options?: RetrieveOptions): Promise<Response>; set(key: string, value: string | Record<string, any>, options?: StoreOptions): Promise<Response>; add(key: string, value: string | Record<string, any>, options?: StoreOptions): Promise<Response>; append(key: string, value: string | Record<string, any>, options?: StoreOptions): Promise<Response>; prepend(key: string, value: string | Record<string, any>, options?: StoreOptions): Promise<Response>; replace(key: string, value: string | Record<string, any>, options?: StoreOptions): Promise<Response>; cas(key: string, value: string | Record<string, any>, casId: number, options?: StoreOptions): Promise<Response>; gat(keys: string | Array<string>, expire: number, options?: RetrieveOptions): Promise<Response>; gats(keys: string | Array<string>, expire: number, options?: RetrieveOptions): Promise<Response>; delete(key: string): Promise<Response>; remove(url: string): void; touch(key: string, expire: number): Promise<Response>; stats(): Promise<StatsResponse>; private _connect; private _cmd; private _handleSocketClose; private _mergeMultiGet; private _remove; private _retry; private _serialize; private _deserialize; private _setStatus; } export declare function createConnection(args: ConnectionConfig, options?: ConnectionOptions): Connection; export {};