UNPKG

@valkey/valkey-glide

Version:

General Language Independent Driver for the Enterprise (GLIDE) for Valkey

1,468 lines 65.2 kB
/** * Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */ import { GlideRecord, GlideString, HashDataType, Score, ObjectType, SortedSetDataType, ElementAndScore } from "./BaseClient"; import { command_request } from "./ProtobufMessage"; /** * @internal */ export declare function parseInfoResponse(response: string): Record<string, string>; /** * @internal */ export declare function createGet(key: GlideString): command_request.Command; /** * @internal */ export declare function createGetDel(key: GlideString): command_request.Command; /** * @internal */ export declare function createGetRange(key: GlideString, start: number, end: number): command_request.Command; export type SetOptions = ({ /** * `onlyIfDoesNotExist` - Only set the key if it does not already exist. * `NX` in the Valkey API. * * `onlyIfExists` - Only set the key if it already exists. * `EX` in the Valkey API. */ conditionalSet?: "onlyIfExists" | "onlyIfDoesNotExist"; } | { /** * `onlyIfEqual` - Only set the key if the comparison value equals the current value of key. * `IFEQ` in the Valkey API. */ conditionalSet: "onlyIfEqual"; /** * The value to compare the existing value with. */ comparisonValue: GlideString; }) & { /** * Return the old string stored at key, or nil if key did not exist. An error * is returned and SET aborted if the value stored at key is not a string. * Equivalent to `GET` in the Valkey API. */ returnOldValue?: boolean; /** * If not set, no expiry time will be set for the value. */ expiry?: "keepExisting" | { type: TimeUnit; count: number; }; }; /** * @internal */ export declare function createSet(key: GlideString, value: GlideString, options?: SetOptions): command_request.Command; /** * INFO option: a specific section of information: * When no parameter is provided, the default option is assumed. */ export declare enum InfoOptions { /** * SERVER: General information about the server */ Server = "server", /** * CLIENTS: Client connections section */ Clients = "clients", /** * MEMORY: Memory consumption related information */ Memory = "memory", /** * PERSISTENCE: RDB and AOF related information */ Persistence = "persistence", /** * STATS: General statistics */ Stats = "stats", /** * REPLICATION: Master/replica replication information */ Replication = "replication", /** * CPU: CPU consumption statistics */ Cpu = "cpu", /** * COMMANDSTATS: Valkey command statistics */ Commandstats = "commandstats", /** * LATENCYSTATS: Valkey command latency percentile distribution statistics */ Latencystats = "latencystats", /** * SENTINEL: Valkey Sentinel section (only applicable to Sentinel instances) */ Sentinel = "sentinel", /** * CLUSTER: Valkey Cluster section */ Cluster = "cluster", /** * MODULES: Modules section */ Modules = "modules", /** * KEYSPACE: Database related statistics */ Keyspace = "keyspace", /** * ERRORSTATS: Valkey error statistics */ Errorstats = "errorstats", /** * ALL: Return all sections (excluding module generated ones) */ All = "all", /** * DEFAULT: Return only the default set of sections */ Default = "default", /** * EVERYTHING: Includes all and modules */ Everything = "everything" } /** * @internal */ export declare function createPing(str?: GlideString): command_request.Command; /** * @internal */ export declare function createInfo(options?: InfoOptions[]): command_request.Command; /** * @internal */ export declare function createDel(keys: GlideString[]): command_request.Command; /** * @internal */ export declare function createSelect(index: number): command_request.Command; /** * @internal */ export declare function createClientGetName(): command_request.Command; /** * @internal */ export declare function createConfigRewrite(): command_request.Command; /** * @internal */ export declare function createConfigResetStat(): command_request.Command; /** * @internal */ export declare function createMGet(keys: GlideString[]): command_request.Command; /** * @internal */ export declare function createMSet(keysAndValues: GlideRecord<GlideString>): command_request.Command; /** * @internal */ export declare function createMSetNX(keysAndValues: GlideRecord<GlideString>): command_request.Command; /** * @internal */ export declare function createIncr(key: GlideString): command_request.Command; /** * @internal */ export declare function createIncrBy(key: GlideString, amount: number): command_request.Command; /** * @internal */ export declare function createIncrByFloat(key: GlideString, amount: number): command_request.Command; /** * @internal */ export declare function createClientId(): command_request.Command; /** * @internal */ export declare function createConfigGet(parameters: string[]): command_request.Command; /** * @internal */ export declare function createConfigSet(parameters: Record<string, GlideString>): command_request.Command; /** * @internal */ export declare function createHGet(key: GlideString, field: GlideString): command_request.Command; /** * This function converts an input from {@link HashDataType} or `Record` types to `HashDataType`. * * @param fieldsAndValues - field names and their values. * @returns HashDataType array containing field names and their values. */ export declare function convertFieldsAndValuesToHashDataType(fieldsAndValues: HashDataType | Record<string, GlideString>): HashDataType; /** * @internal */ export declare function createHSet(key: GlideString, fieldValueList: HashDataType): command_request.Command; /** * @internal */ export declare function createHKeys(key: GlideString): command_request.Command; /** * @internal */ export declare function createHSetNX(key: GlideString, field: GlideString, value: GlideString): command_request.Command; /** * @internal */ export declare function createDecr(key: GlideString): command_request.Command; /** * @internal */ export declare function createDecrBy(key: GlideString, amount: number): command_request.Command; /** * Enumeration defining the bitwise operation to use in the {@link BaseClient.bitop|bitop} command. Specifies the * bitwise operation to perform between the passed in keys. */ export declare enum BitwiseOperation { AND = "AND", OR = "OR", XOR = "XOR", NOT = "NOT" } /** * @internal */ export declare function createBitOp(operation: BitwiseOperation, destination: GlideString, keys: GlideString[]): command_request.Command; /** * @internal */ export declare function createGetBit(key: GlideString, offset: number): command_request.Command; /** * @internal */ export declare function createSetBit(key: GlideString, offset: number, value: number): command_request.Command; /** * Represents a signed or unsigned argument encoding for the {@link BaseClient.bitfield|bitfield} or * {@link BaseClient.bitfieldReadOnly|bitfieldReadOnly} commands. */ export interface BitEncoding { /** * Returns the encoding as a string argument to be used in the {@link BaseClient.bitfield|bitfield} or * {@link BaseClient.bitfieldReadOnly|bitfieldReadOnly} commands. * * @returns The encoding as a string argument. */ toArg(): string; } /** * Represents a signed argument encoding. */ export declare class SignedEncoding implements BitEncoding { private static readonly SIGNED_ENCODING_PREFIX; private readonly encoding; /** * Creates an instance of SignedEncoding. * * @param encodingLength - The bit size of the encoding. Must be less than 65 bits long. */ constructor(encodingLength: number); toArg(): string; } /** * Represents an unsigned argument encoding. */ export declare class UnsignedEncoding implements BitEncoding { private static readonly UNSIGNED_ENCODING_PREFIX; private readonly encoding; /** * Creates an instance of UnsignedEncoding. * * @param encodingLength - The bit size of the encoding. Must be less than 64 bits long. */ constructor(encodingLength: number); toArg(): string; } /** * Represents an offset for an array of bits for the {@link BaseClient.bitfield|bitfield} or * {@link BaseClient.bitfieldReadOnly|bitfieldReadOnly} commands. */ export interface BitFieldOffset { /** * Returns the offset as a string argument to be used in the {@link BaseClient.bitfield|bitfield} or * {@link BaseClient.bitfieldReadOnly|bitfieldReadOnly} commands. * * @returns The offset as a string argument. */ toArg(): string; } /** * Represents an offset in an array of bits for the {@link BaseClient.bitfield|bitfield} or * {@link BaseClient.bitfieldReadOnly|bitfieldReadOnly} commands. * * For example, if we have the binary `01101001` with offset of 1 for an unsigned encoding of size 4, then the value * is 13 from `0(1101)001`. */ export declare class BitOffset implements BitFieldOffset { private readonly offset; /** * Creates an instance of BitOffset. * * @param offset - The bit index offset in the array of bits. Must be greater than or equal to 0. */ constructor(offset: number); toArg(): string; } /** * Represents an offset in an array of bits for the {@link BaseClient.bitfield|bitfield} or * {@link BaseClient.bitfieldReadOnly|bitfieldReadOnly} commands. The bit offset index is calculated as the numerical * value of the offset multiplied by the encoding value. * * For example, if we have the binary 01101001 with offset multiplier of 1 for an unsigned encoding of size 4, then the * value is 9 from `0110(1001)`. */ export declare class BitOffsetMultiplier implements BitFieldOffset { private static readonly OFFSET_MULTIPLIER_PREFIX; private readonly offset; /** * Creates an instance of BitOffsetMultiplier. * * @param offset - The offset in the array of bits, which will be multiplied by the encoding value to get the final * bit index offset. */ constructor(offset: number); toArg(): string; } /** * Represents subcommands for the {@link BaseClient.bitfield|bitfield} or * {@link BaseClient.bitfieldReadOnly|bitfieldReadOnly} commands. */ export interface BitFieldSubCommands { /** * Returns the subcommand as a list of string arguments to be used in the {@link BaseClient.bitfield|bitfield} or * {@link BaseClient.bitfieldReadOnly|bitfieldReadOnly} commands. * * @returns The subcommand as a list of string arguments. */ toArgs(): string[]; } /** * Represents the "GET" subcommand for getting a value in the binary representation of the string stored in `key`. */ export declare class BitFieldGet implements BitFieldSubCommands { private static readonly GET_COMMAND_STRING; private readonly encoding; private readonly offset; /** * Creates an instance of BitFieldGet. * * @param encoding - The bit encoding for the subcommand. * @param offset - The offset in the array of bits from which to get the value. */ constructor(encoding: BitEncoding, offset: BitFieldOffset); toArgs(): string[]; } /** * Represents the "SET" subcommand for setting bits in the binary representation of the string stored in `key`. */ export declare class BitFieldSet implements BitFieldSubCommands { private static readonly SET_COMMAND_STRING; private readonly encoding; private readonly offset; private readonly value; /** * Creates an instance of BitFieldSet * * @param encoding - The bit encoding for the subcommand. * @param offset - The offset in the array of bits where the value will be set. * @param value - The value to set the bits in the binary value to. */ constructor(encoding: BitEncoding, offset: BitFieldOffset, value: number); toArgs(): string[]; } /** * Represents the "INCRBY" subcommand for increasing or decreasing bits in the binary representation of the string * stored in `key`. */ export declare class BitFieldIncrBy implements BitFieldSubCommands { private static readonly INCRBY_COMMAND_STRING; private readonly encoding; private readonly offset; private readonly increment; /** * Creates an instance of BitFieldIncrBy * * @param encoding - The bit encoding for the subcommand. * @param offset - The offset in the array of bits where the value will be incremented. * @param increment - The value to increment the bits in the binary value by. */ constructor(encoding: BitEncoding, offset: BitFieldOffset, increment: number); toArgs(): string[]; } /** * Enumeration specifying bit overflow controls for the {@link BaseClient.bitfield|bitfield} command. */ export declare enum BitOverflowControl { /** * Performs modulo when overflows occur with unsigned encoding. When overflows occur with signed encoding, the value * restarts at the most negative value. When underflows occur with signed encoding, the value restarts at the most * positive value. */ WRAP = "WRAP", /** * Underflows remain set to the minimum value, and overflows remain set to the maximum value. */ SAT = "SAT", /** * Returns `None` when overflows occur. */ FAIL = "FAIL" } /** * Represents the "OVERFLOW" subcommand that determines the result of the "SET" or "INCRBY" * {@link BaseClient.bitfield|bitfield} subcommands when an underflow or overflow occurs. */ export declare class BitFieldOverflow implements BitFieldSubCommands { private static readonly OVERFLOW_COMMAND_STRING; private readonly overflowControl; /** * Creates an instance of BitFieldOverflow. * * @param overflowControl - The desired overflow behavior. */ constructor(overflowControl: BitOverflowControl); toArgs(): string[]; } /** * @internal */ export declare function createBitField(key: GlideString, subcommands: BitFieldSubCommands[], readOnly?: boolean): command_request.Command; /** * @internal */ export declare function createHDel(key: GlideString, fields: GlideString[]): command_request.Command; /** * @internal */ export declare function createHMGet(key: GlideString, fields: GlideString[]): command_request.Command; /** * @internal */ export declare function createHExists(key: GlideString, field: GlideString): command_request.Command; /** * @internal */ export declare function createHGetAll(key: GlideString): command_request.Command; /** * @internal */ export declare function createLPush(key: GlideString, elements: GlideString[]): command_request.Command; /** * @internal */ export declare function createLPushX(key: GlideString, elements: GlideString[]): command_request.Command; /** * @internal */ export declare function createLPop(key: GlideString, count?: number): command_request.Command; /** * @internal */ export declare function createLRange(key: GlideString, start: number, end: number): command_request.Command; /** * @internal */ export declare function createLLen(key: GlideString): command_request.Command; /** * Enumeration representing element popping or adding direction for the List Based Commands. */ export declare enum ListDirection { /** * Represents the option that elements should be popped from or added to the left side of a list. */ LEFT = "LEFT", /** * Represents the option that elements should be popped from or added to the right side of a list. */ RIGHT = "RIGHT" } /** * @internal */ export declare function createLMove(source: GlideString, destination: GlideString, whereFrom: ListDirection, whereTo: ListDirection): command_request.Command; /** * @internal */ export declare function createBLMove(source: GlideString, destination: GlideString, whereFrom: ListDirection, whereTo: ListDirection, timeout: number): command_request.Command; /** * @internal */ export declare function createLSet(key: GlideString, index: number, element: GlideString): command_request.Command; /** * @internal */ export declare function createLTrim(key: GlideString, start: number, end: number): command_request.Command; /** * @internal */ export declare function createLRem(key: GlideString, count: number, element: GlideString): command_request.Command; /** * @internal */ export declare function createRPush(key: GlideString, elements: GlideString[]): command_request.Command; /** * @internal */ export declare function createRPushX(key: GlideString, elements: GlideString[]): command_request.Command; /** * @internal */ export declare function createRPop(key: GlideString, count?: number): command_request.Command; /** * @internal */ export declare function createSAdd(key: GlideString, members: GlideString[]): command_request.Command; /** * @internal */ export declare function createSRem(key: GlideString, members: GlideString[]): command_request.Command; /** * @internal */ export declare function createSScan(key: GlideString, cursor: GlideString, options?: BaseScanOptions): command_request.Command; /** * @internal */ export declare function createSMembers(key: GlideString): command_request.Command; /** * * @internal */ export declare function createSMove(source: GlideString, destination: GlideString, member: GlideString): command_request.Command; /** * @internal */ export declare function createSCard(key: GlideString): command_request.Command; /** * @internal */ export declare function createSInter(keys: GlideString[]): command_request.Command; /** * @internal */ export declare function createSInterCard(keys: GlideString[], limit?: number): command_request.Command; /** * @internal */ export declare function createSInterStore(destination: GlideString, keys: GlideString[]): command_request.Command; /** * @internal */ export declare function createSDiff(keys: GlideString[]): command_request.Command; /** * @internal */ export declare function createSDiffStore(destination: GlideString, keys: GlideString[]): command_request.Command; /** * @internal */ export declare function createSUnion(keys: GlideString[]): command_request.Command; /** * @internal */ export declare function createSUnionStore(destination: GlideString, keys: GlideString[]): command_request.Command; /** * @internal */ export declare function createSIsMember(key: GlideString, member: GlideString): command_request.Command; /** * @internal */ export declare function createSMIsMember(key: GlideString, members: GlideString[]): command_request.Command; /** * @internal */ export declare function createSPop(key: GlideString, count?: number): command_request.Command; /** * @internal */ export declare function createSRandMember(key: GlideString, count?: number): command_request.Command; /** * @internal */ export declare function createCustomCommand(args: GlideString[]): command_request.Command; /** * @internal */ export declare function createHIncrBy(key: GlideString, field: GlideString, amount: number): command_request.Command; /** * @internal */ export declare function createHIncrByFloat(key: GlideString, field: GlideString, amount: number): command_request.Command; /** * @internal */ export declare function createHLen(key: GlideString): command_request.Command; /** * @internal */ export declare function createHVals(key: GlideString): command_request.Command; /** * @internal */ export declare function createExists(keys: GlideString[]): command_request.Command; /** * @internal */ export declare function createUnlink(keys: GlideString[]): command_request.Command; export declare enum ExpireOptions { /** * `HasNoExpiry` - Sets expiry only when the key has no expiry. */ HasNoExpiry = "NX", /** * `HasExistingExpiry` - Sets expiry only when the key has an existing expiry. */ HasExistingExpiry = "XX", /** * `NewExpiryGreaterThanCurrent` - Sets expiry only when the new expiry is * greater than current one. */ NewExpiryGreaterThanCurrent = "GT", /** * `NewExpiryLessThanCurrent` - Sets expiry only when the new expiry is less * than current one. */ NewExpiryLessThanCurrent = "LT" } /** * @internal */ export declare function createExpire(key: GlideString, seconds: number, option?: ExpireOptions): command_request.Command; /** * @internal */ export declare function createExpireAt(key: GlideString, unixSeconds: number, option?: ExpireOptions): command_request.Command; /** * @internal */ export declare function createExpireTime(key: GlideString): command_request.Command; /** * @internal */ export declare function createPExpire(key: GlideString, milliseconds: number, option?: ExpireOptions): command_request.Command; /** * @internal */ export declare function createPExpireAt(key: GlideString, unixMilliseconds: number, option?: ExpireOptions): command_request.Command; /** * @internal */ export declare function createPExpireTime(key: GlideString): command_request.Command; /** * @internal */ export declare function createTTL(key: GlideString): command_request.Command; /** * Options for updating elements of a sorted set key. */ export declare enum UpdateByScore { /** Only update existing elements if the new score is less than the current score. */ LESS_THAN = "LT", /** Only update existing elements if the new score is greater than the current score. */ GREATER_THAN = "GT" } export interface ZAddOptions { /** * Options for handling existing members. */ conditionalChange?: ConditionalChange; /** * Options for updating scores. */ updateOptions?: UpdateByScore; /** * Modify the return value from the number of new elements added, to the total number of elements changed. */ changed?: boolean; } /** * @internal * Convert input from `Record` to `SortedSetDataType` to ensure the only one type. */ export declare function convertElementsAndScores(membersAndScores: SortedSetDataType | Record<string, number>): SortedSetDataType; /** * @internal */ export declare function createZAdd(key: GlideString, membersAndScores: ElementAndScore[] | Record<string, Score>, options?: ZAddOptions, incr?: boolean): command_request.Command; /** * `KeyWeight` - pair of variables represents a weighted key for the `ZINTERSTORE` and `ZUNIONSTORE` sorted sets commands. */ export type KeyWeight = [GlideString, number]; /** * `AggregationType` - representing aggregation types for `ZINTERSTORE` and `ZUNIONSTORE` sorted set commands. */ export type AggregationType = "SUM" | "MIN" | "MAX"; /** * @internal */ export declare function createZInterstore(destination: GlideString, keys: GlideString[] | KeyWeight[], aggregationType?: AggregationType): command_request.Command; /** * @internal */ export declare function createZInter(keys: GlideString[] | KeyWeight[], aggregationType?: AggregationType, withScores?: boolean): command_request.Command; /** * @internal */ export declare function createZUnion(keys: GlideString[] | KeyWeight[], aggregationType?: AggregationType, withScores?: boolean): command_request.Command; /** * @internal */ export declare function createZRem(key: GlideString, members: GlideString[]): command_request.Command; /** * @internal */ export declare function createZCard(key: GlideString): command_request.Command; /** * @internal */ export declare function createZInterCard(keys: GlideString[], limit?: number): command_request.Command; /** * @internal */ export declare function createZDiff(keys: GlideString[]): command_request.Command; /** * @internal */ export declare function createZDiffWithScores(keys: GlideString[]): command_request.Command; /** * @internal */ export declare function createZDiffStore(destination: GlideString, keys: GlideString[]): command_request.Command; /** * @internal */ export declare function createZScore(key: GlideString, member: GlideString): command_request.Command; /** * @internal */ export declare function createZUnionStore(destination: GlideString, keys: GlideString[] | KeyWeight[], aggregationType?: AggregationType): command_request.Command; /** * @internal */ export declare function createZMScore(key: GlideString, members: GlideString[]): command_request.Command; /** * @internal */ export declare function createScan(cursor: GlideString, options?: ScanOptions): command_request.Command; export declare enum InfBoundary { /** * Positive infinity bound. */ PositiveInfinity = "+", /** * Negative infinity bound. */ NegativeInfinity = "-" } /** * Defines the boundaries of a range. */ export type Boundary<T> = /** * Represents an lower/upper boundary. */ InfBoundary /** * Represents a specific boundary. */ | { /** * The comparison value. */ value: T; /** * Whether the value is inclusive. Defaults to `true`. */ isInclusive?: boolean; }; /** * Represents a range by index (rank) in a sorted set. * The `start` and `end` arguments represent zero-based indexes. */ export interface RangeByIndex { /** * The start index of the range. */ start: number; /** * The end index of the range. */ end: number; } /** * Represents a range by score or a range by lex in a sorted set. * The `start` and `end` arguments represent score boundaries. */ interface SortedSetRange<T> { /** * The start boundary. */ start: Boundary<T>; /** * The end boundary. */ end: Boundary<T>; /** * The limit argument for a range query. * Represents a limit argument for a range query in a sorted set to * be used in [ZRANGE](https://valkey.io/commands/zrange) command. * * The optional LIMIT argument can be used to obtain a sub-range from the * matching elements (similar to SELECT LIMIT offset, count in SQL). */ limit?: { /** * The offset from the start of the range. */ offset: number; /** * The number of elements to include in the range. * A negative count returns all elements from the offset. */ count: number; }; } export type RangeByScore = SortedSetRange<number> & { type: "byScore"; }; export type RangeByLex = SortedSetRange<GlideString> & { type: "byLex"; }; /** * @internal */ export declare function createZCount(key: GlideString, minScore: Boundary<number>, maxScore: Boundary<number>): command_request.Command; /** * @internal */ export declare function createZRange(key: GlideString, rangeQuery: RangeByIndex | RangeByScore | RangeByLex, reverse?: boolean): command_request.Command; /** * @internal */ export declare function createZRangeWithScores(key: GlideString, rangeQuery: RangeByIndex | RangeByScore | RangeByLex, reverse?: boolean): command_request.Command; /** * @internal */ export declare function createZRangeStore(destination: GlideString, source: GlideString, rangeQuery: RangeByIndex | RangeByScore | RangeByLex, reverse?: boolean): command_request.Command; /** * @internal */ export declare function createType(key: GlideString): command_request.Command; /** * @internal */ export declare function createStrlen(key: GlideString): command_request.Command; /** * @internal */ export declare function createLIndex(key: GlideString, index: number): command_request.Command; /** * Defines where to insert new elements into a list. */ export declare enum InsertPosition { /** * Insert new element before the pivot. */ Before = "before", /** * Insert new element after the pivot. */ After = "after" } /** * @internal */ export declare function createLInsert(key: GlideString, position: InsertPosition, pivot: GlideString, element: GlideString): command_request.Command; /** * @internal */ export declare function createZPopMin(key: GlideString, count?: number): command_request.Command; /** * @internal */ export declare function createZPopMax(key: GlideString, count?: number): command_request.Command; /** * @internal */ export declare function createEcho(message: GlideString): command_request.Command; /** * @internal */ export declare function createPTTL(key: GlideString): command_request.Command; /** * @internal */ export declare function createZRemRangeByRank(key: GlideString, start: number, end: number): command_request.Command; /** * @internal */ export declare function createZRemRangeByLex(key: GlideString, minLex: Boundary<GlideString>, maxLex: Boundary<GlideString>): command_request.Command; /** * @internal */ export declare function createZRemRangeByScore(key: GlideString, minScore: Boundary<number>, maxScore: Boundary<number>): command_request.Command; /** @internal */ export declare function createPersist(key: GlideString): command_request.Command; /** * @internal */ export declare function createZLexCount(key: GlideString, minLex: Boundary<GlideString>, maxLex: Boundary<GlideString>): command_request.Command; /** @internal */ export declare function createZRank(key: GlideString, member: GlideString, withScores?: boolean): command_request.Command; export type StreamTrimOptions = ({ /** * Trim the stream according to entry ID. * Equivalent to `MINID` in the Valkey API. */ method: "minid"; threshold: GlideString; } | { /** * Trim the stream according to length. * Equivalent to `MAXLEN` in the Valkey API. */ method: "maxlen"; threshold: number; }) & { /** * If `true`, the stream will be trimmed exactly. Equivalent to `=` in the * Valkey API. Otherwise the stream will be trimmed in a near-exact manner, * which is more efficient, equivalent to `~` in the Valkey API. */ exact: boolean; /** * If set, sets the maximal amount of entries that will be deleted. */ limit?: number; }; export interface StreamAddOptions { /** * If set, the new entry will be added with this ID. */ id?: string; /** * If set to `false`, a new stream won't be created if no stream matches the * given key. Equivalent to `NOMKSTREAM` in the Valkey API. */ makeStream?: boolean; /** * If set, the add operation will also trim the older entries in the stream. */ trim?: StreamTrimOptions; } /** * @internal */ export declare function createXAdd(key: GlideString, values: [GlideString, GlideString][], options?: StreamAddOptions): command_request.Command; /** * @internal */ export declare function createXDel(key: GlideString, ids: string[]): command_request.Command; /** * @internal */ export declare function createXTrim(key: GlideString, options: StreamTrimOptions): command_request.Command; /** * @internal */ export declare function createXRange(key: GlideString, start: Boundary<string>, end: Boundary<string>, count?: number): command_request.Command; /** * @internal */ export declare function createXRevRange(key: GlideString, start: Boundary<string>, end: Boundary<string>, count?: number): command_request.Command; /** * @internal */ export declare function createXGroupCreateConsumer(key: GlideString, groupName: GlideString, consumerName: GlideString): command_request.Command; /** * @internal */ export declare function createXGroupDelConsumer(key: GlideString, groupName: GlideString, consumerName: GlideString): command_request.Command; /** * @internal */ export declare function createTime(): command_request.Command; /** * @internal */ export declare function createPublish(message: GlideString, channel: GlideString, sharded?: boolean): command_request.Command; /** * @internal */ export declare function createBRPop(keys: GlideString[], timeout: number): command_request.Command; /** * @internal */ export declare function createBLPop(keys: GlideString[], timeout: number): command_request.Command; /** * @internal */ export declare function createFCall(func: GlideString, keys: GlideString[], args: GlideString[]): command_request.Command; /** * @internal */ export declare function createFCallReadOnly(func: GlideString, keys: GlideString[], args: GlideString[]): command_request.Command; /** * @internal */ export declare function createFunctionDelete(libraryCode: GlideString): command_request.Command; /** * @internal */ export declare function createFunctionFlush(mode?: FlushMode): command_request.Command; /** * @internal */ export declare function createFunctionLoad(libraryCode: GlideString, replace?: boolean): command_request.Command; /** Optional arguments for `FUNCTION LIST` command. */ export interface FunctionListOptions { /** A wildcard pattern for matching library names. */ libNamePattern?: GlideString; /** Specifies whether to request the library code from the server or not. */ withCode?: boolean; } /** Type of the response of `FUNCTION LIST` command. */ export type FunctionListResponse = Record<string, GlideString | Record<string, GlideString | null | GlideString[]>[]>[]; /** * @internal */ export declare function createFunctionList(options?: FunctionListOptions): command_request.Command; /** Response for `FUNCTION STATS` command on a single node. * The response is a map with 2 keys: * 1. Information about the current running function/script (or null if none). * 2. Details about the execution engines. */ export type FunctionStatsSingleResponse = Record<string, null | Record<string, GlideString | GlideString[] | number> | Record<string, Record<string, number>>>; /** Full response for `FUNCTION STATS` command across multiple nodes. * It maps node addresses to the per-node response. */ export type FunctionStatsFullResponse = Record<string, // Node address FunctionStatsSingleResponse>; /** @internal */ export declare function createFunctionStats(): command_request.Command; /** @internal */ export declare function createFunctionKill(): command_request.Command; /** @internal */ export declare function createFunctionDump(): command_request.Command; /** * Option for `FUNCTION RESTORE` command: {@link GlideClient.functionRestore} and * {@link GlideClusterClient.functionRestore}. * * @see {@link https://valkey.io/commands/function-restore/"|valkey.io} for more details. */ export declare enum FunctionRestorePolicy { /** * Appends the restored libraries to the existing libraries and aborts on collision. This is the * default policy. */ APPEND = "APPEND", /** Deletes all existing libraries before restoring the payload. */ FLUSH = "FLUSH", /** * Appends the restored libraries to the existing libraries, replacing any existing ones in case * of name collisions. Note that this policy doesn't prevent function name collisions, only * libraries. */ REPLACE = "REPLACE" } /** @internal */ export declare function createFunctionRestore(data: Buffer, policy?: FunctionRestorePolicy): command_request.Command; /** * Represents offsets specifying a string interval to analyze in the {@link BaseClient.bitcount | bitcount} and {@link BaseClient.bitpos | bitpos} commands. * The offsets are zero-based indexes, with `0` being the first index of the string, `1` being the next index and so on. * The offsets can also be negative numbers indicating offsets starting at the end of the string, with `-1` being * the last index of the string, `-2` being the penultimate, and so on. * * If you are using Valkey 7.0.0 or above, the optional `indexType` can also be provided to specify whether the * `start` and `end` offsets specify `BIT` or `BYTE` offsets. If `indexType` is not provided, `BYTE` offsets * are assumed. If `BIT` is specified, `start=0` and `end=2` means to look at the first three bits. If `BYTE` is * specified, `start=0` and `end=2` means to look at the first three bytes. * * @see {@link https://valkey.io/commands/bitcount/ | bitcount} and {@link https://valkey.io/commands/bitpos/ | bitpos} for more details. */ export interface BitOffsetOptions { /** The starting offset index. */ start: number; /** * The ending offset index. Optional since Valkey version 8.0 and above for the BITCOUNT command. * If not provided, it will default to the end of the string. * Could be defined only if `start` is defined. */ end?: number; /** * The index offset type. This option can only be specified if you are using server version 7.0.0 or above. * Could be either {@link BitmapIndexType.BYTE} or {@link BitmapIndexType.BIT}. * If no index type is provided, the indexes will be assumed to be byte indexes. */ indexType?: BitmapIndexType; } /** * @internal */ export declare function createBitCount(key: GlideString, options?: BitOffsetOptions): command_request.Command; /** * Enumeration specifying if index arguments are BYTE indexes or BIT indexes. * Can be specified in {@link BitOffsetOptions}, which is an optional argument to the {@link BaseClient.bitcount|bitcount} command. * Can also be specified as an optional argument to the {@link BaseClient.bitposInverval|bitposInterval} command. * * since - Valkey version 7.0.0. */ export declare enum BitmapIndexType { /** Specifies that provided indexes are byte indexes. */ BYTE = "BYTE", /** Specifies that provided indexes are bit indexes. */ BIT = "BIT" } /** * @internal */ export declare function createBitPos(key: GlideString, bit: number, options?: BitOffsetOptions): command_request.Command; /** * Defines flushing mode for {@link GlideClient.flushall}, {@link GlideClusterClient.flushall}, * {@link GlideClient.functionFlush}, {@link GlideClusterClient.functionFlush}, * {@link GlideClient.flushdb} and {@link GlideClusterClient.flushdb} commands. * * See https://valkey.io/commands/flushall/ and https://valkey.io/commands/flushdb/ for details. */ export declare enum FlushMode { /** * Flushes synchronously. * * since Valkey version 6.2.0. */ SYNC = "SYNC", /** Flushes asynchronously. */ ASYNC = "ASYNC" } /** * @internal * This function converts an input from Record or GlideRecord types to GlideRecord. * * @param record - input record in either Record or GlideRecord types. * @returns same data in GlideRecord type. */ export declare function convertKeysAndEntries(record: Record<string, string> | GlideRecord<string>): GlideRecord<string>; /** Optional arguments for {@link BaseClient.xread|xread} command. */ export interface StreamReadOptions { /** * If set, the read request will block for the set amount of milliseconds or * until the server has the required number of entries. A value of `0` will block indefinitely. * Equivalent to `BLOCK` in the Valkey API. */ block?: number; /** * The maximal number of elements requested. * Equivalent to `COUNT` in the Valkey API. */ count?: number; } /** Optional arguments for {@link BaseClient.xreadgroup|xreadgroup} command. */ export type StreamReadGroupOptions = StreamReadOptions & { /** * If set, messages are not added to the Pending Entries List (PEL). This is equivalent to * acknowledging the message when it is read. */ noAck?: boolean; }; /** * @internal */ export declare function createXRead(keys_and_ids: GlideRecord<string>, options?: StreamReadOptions): command_request.Command; /** @internal */ export declare function createXReadGroup(group: GlideString, consumer: GlideString, keys_and_ids: GlideRecord<string>, options?: StreamReadGroupOptions): command_request.Command; /** * @internal */ export declare function createXInfoStream(key: GlideString, options: boolean | number): command_request.Command; /** @internal */ export declare function createXInfoGroups(key: GlideString): command_request.Command; /** * @internal */ export declare function createXLen(key: GlideString): command_request.Command; /** Optional arguments for {@link BaseClient.xpendingWithOptions|xpending}. */ export interface StreamPendingOptions { /** Filter pending entries by their idle time - in milliseconds. Available since Valkey 6.2.0. */ minIdleTime?: number; /** Starting stream ID bound for range. Exclusive range is available since Valkey 6.2.0. */ start: Boundary<string>; /** Ending stream ID bound for range. Exclusive range is available since Valkey 6.2.0. */ end: Boundary<string>; /** Limit the number of messages returned. */ count: number; /** Filter pending entries by consumer. */ consumer?: GlideString; } /** @internal */ export declare function createXPending(key: GlideString, group: GlideString, options?: StreamPendingOptions): command_request.Command; /** @internal */ export declare function createXInfoConsumers(key: GlideString, group: GlideString): command_request.Command; /** Optional parameters for {@link BaseClient.xclaim|xclaim} command. */ export interface StreamClaimOptions { /** * Set the idle time (last time it was delivered) of the message in milliseconds. If `idle` * is not specified, an `idle` of `0` is assumed, that is, the time count is reset * because the message now has a new owner trying to process it. */ idle?: number; /** * This is the same as {@link idle} but instead of a relative amount of milliseconds, it sets the * idle time to a specific Unix time (in milliseconds). This is useful in order to rewrite the AOF * file generating `XCLAIM` commands. */ idleUnixTime?: number; /** * Set the retry counter to the specified value. This counter is incremented every time a message * is delivered again. Normally {@link BaseClient.xclaim|xclaim} does not alter this counter, * which is just served to clients when the {@link BaseClient.xpending|xpending} command is called: * this way clients can detect anomalies, like messages that are never processed for some reason * after a big number of delivery attempts. */ retryCount?: number; /** * Creates the pending message entry in the PEL even if certain specified IDs are not already in * the PEL assigned to a different client. However, the message must exist in the stream, * otherwise the IDs of non-existing messages are ignored. */ isForce?: boolean; } /** @internal */ export declare function createXClaim(key: GlideString, group: GlideString, consumer: GlideString, minIdleTime: number, ids: string[], options?: StreamClaimOptions, justId?: boolean): command_request.Command; /** @internal */ export declare function createXAutoClaim(key: GlideString, group: GlideString, consumer: GlideString, minIdleTime: number, start: GlideString, count?: number, justId?: boolean): command_request.Command; /** * Optional arguments for {@link BaseClient.xgroupCreate|xgroupCreate}. * * See https://valkey.io/commands/xgroup-create/ for more details. */ export interface StreamGroupOptions { /** * If `true`and the stream doesn't exist, creates a new stream with a length of `0`. */ mkStream?: boolean; /** * An arbitrary ID (that isn't the first ID, last ID, or the zero `"0-0"`. Use it to * find out how many entries are between the arbitrary ID (excluding it) and the stream's last * entry. * * since Valkey version 7.0.0. */ entriesRead?: string; } /** * @internal */ export declare function createXGroupCreate(key: GlideString, groupName: GlideString, id: string, options?: StreamGroupOptions): command_request.Command; /** * @internal */ export declare function createXGroupDestroy(key: GlideString, groupName: GlideString): command_request.Command; /** * @internal */ export declare function createRename(key: GlideString, newKey: GlideString): command_request.Command; /** * @internal */ export declare function createRenameNX(key: GlideString, newKey: GlideString): command_request.Command; /** * @internal */ export declare function createPfAdd(key: GlideString, elements: GlideString[]): command_request.Command; /** * @internal */ export declare function createPfCount(keys: GlideString[]): command_request.Command; /** * @internal */ export declare function createPfMerge(destination: GlideString, sourceKey: GlideString[]): command_request.Command; /** * @internal */ export declare function createObjectEncoding(key: GlideString): command_request.Command; /** * @internal */ export declare function createObjectFreq(key: GlideString): command_request.Command; /** * @internal */ export declare function createObjectIdletime(key: GlideString): command_request.Command; /** * @internal */ export declare function createObjectRefcount(key: GlideString): command_request.Command; /** Additional parameters for `LOLWUT` command. */ export interface LolwutOptions { /** * An optional argument that can be used to specify the version of computer art to generate. */ version?: number; /** * An optional argument that can be used to specify the output: * - For version `5`, those are length of the line, number of squares per row, and number of squares per column. * - For version `6`, those are number of columns and number of lines. */ parameters?: number[]; } /** * @internal */ export declare function createLolwut(options?: LolwutOptions): command_request.Command; /** * @internal */ export declare function createFlushAll(mode?: FlushMode): command_request.Command; /** * @internal */ export declare function createFlushDB(mode?: FlushMode): command_request.Command; /** * @internal */ export declare function createCopy(source: GlideString, destination: GlideString, options?: { destinationDB?: number; replace?: boolean; }): command_request.Command; /** * @internal */ export declare function createMove(key: GlideString, dbIndex: number): command_request.Command; /** * @internal */ export declare function createDump(key: GlideString): command_request.Command; /** * Optional arguments for `RESTORE` command. * * @See {@link https://valkey.io/commands/restore/|valkey.io} for details. * @remarks `IDLETIME` and `FREQ` modifiers cannot be set at the same time. */ export interface RestoreOptions { /** * Set to `true` to replace the key if it exists. */ replace?: boolean; /** * Set to `true` to specify that `ttl` argument of {@link BaseClient.restore} represents * an absolute Unix timestamp (in milliseconds). */ absttl?: boolean; /** * Set the `IDLETIME` option with object idletime to the given key. */ idletime?: number; /** * Set the `FREQ` option with object frequency to the given key. */ frequency?: number; } /** * @internal */ export declare function createRestore(key: GlideString, ttl: number, value: GlideString, options?: RestoreOptions): command_request.Command; /** * Optional arguments to LPOS command. * * See https://valkey.io/commands/lpos/ for more details. */ export interface LPosOptions { /** The rank of the match to return. */ rank?: number; /** The specific number of matching indices from a list. */ count?: number; /** The maximum number of comparisons to make between the element and the items in the list. */ maxLength?: number; } /** * @internal */ export declare function createLPos(key: GlideString, element: GlideString, options?: LPosOptions): command_request.Command; /** * @internal */ export declare function createDBSize(): command_request.Command; /** * An optional condition to the {@link BaseClient.geoadd | geoadd}, * {@link BaseClient.zadd | zadd} and {@link BaseClient.set | set} commands. */ export declare enum ConditionalChange { /** * Only update elements that already exist. Don't add new elements. Equivalent to `XX` in the Valkey API. */ ONLY_IF_EXISTS = "XX", /** * Only add new elements. Don't update already existing elements. Equivalent to `NX` in the Valkey API. */ ONLY_IF_DOES_NOT_EXIST = "NX" } /** * Represents a geographic position defined by longitude and latitude. * The exact limits, as specified by `EPSG:900913 / EPSG:3785 / OSGEO:41001` are the * following: * * Valid longitudes are from `-180` to `180` degrees. * Valid latitudes are from `-85.05112878` to `85.05112878` degrees. */ export interface GeospatialData { /** The longitude coordinate. */ longitude: number; /** The latitude coordinate. */ latitude: number; } /** * Optional arguments for the GeoAdd command. * * See https://valkey.io/commands/geoadd/ for more details. */ export interface GeoAddOptions { /** Options for handling existing members. See {@link ConditionalChange}. */ updateMode?: ConditionalChange; /** If `true`, returns the count of changed elements instead of new elements added. */ changed?: boolean; } /** * @internal */ export declare function createGeoAdd(key: GlideString, membersToGeospatialData: Map<GlideString, GeospatialData>, options?: GeoAddOptions): command_request.Command; /** Enumeration representing distance units options. */ export declare enum GeoUnit { /** Represents distance in meters. */ METERS = "m", /** Represents distance in kilometers. */ KILOMETERS = "km", /** Represents distance in miles. */ MILES = "mi", /** Represents distance in feet. */ FEET = "ft" } /** * @internal */ export declare function createGeoPos(key: GlideString, members: GlideString[]): command_request.Command; /** * @internal */ export declare function createGeoDist(key: GlideString, member1: GlideString, member2: GlideString, geoUnit?: GeoUnit): command_request.Command; /** * @internal */ export declare function cr