Available since v1.0.0

This command implements both INCR and DECR by a flag passed during instantiation.

Increments the number stored at key by one. If the key does not exist, it is set to 0 before performing the operation. An error is returned if the key contains a value of the wrong type or contains a string that can not be represented as integer. This operation is limited to 53 bit signed integers. Note that redis actually supports 64 bit integers, but javascript does not.

Number.MAX_SAFE_INTEGER is 9007199254740991

Note: this is a string operation because Redis does not have a dedicated integer type. The string stored at the key is interpreted as a base-10 53 bit signed integer to execute the operation.

Redis stores integers in their integer representation, so for string values that actually hold an integer, there is no overhead for storing the string representation of the integer.

Return value Integer reply: the value of key after the increment

Hierarchy

Constructors

Properties

blocking?: boolean
dataType?: DataType

Used for "database" commands to enforce type checking.

dbDataType: DataType = DataType.STRING
logger: Logger = ...
maxParams: number = 1

Maximum number of parameters allowed. -1 for no maximum.

minParams: number = 1

Minimum number of parameters require.

name: string = "incr"
pubSubAllowed?: boolean

Used when PUB/SUB is in effect.

sign: number

Sign is used in commands with a compliment command. The only current example is INCR/DECR. Sign is 1 for INCR and -1 for DECR

txIgnore?: boolean

Used in transactions to enqueue a command.

Methods