method

RedisClient.bitop

operation: 'NOT' | 'not',
destkey: KeyLike,
key: KeyLike
): Promise<number>;

Perform a bitwise NOT on a key and store the result in the destination key

@param operation

The bitwise operation (NOT takes exactly one source key)

@param destkey

The destination key to store the result

@param key

The source key

@returns

Promise that resolves with the size of the string stored in the destination key

await redis.set("key1", "foobar");
await redis.bitop("NOT", "dest", "key1");
operation: 'AND' | 'OR' | 'XOR' | 'DIFF' | 'DIFF1' | 'ANDOR' | 'ONE' | 'and' | 'or' | 'xor' | 'diff' | 'diff1' | 'andor' | 'one',
destkey: KeyLike,
key: KeyLike,
...moreKeys: KeyLike[]
): Promise<number>;

Perform a bitwise operation between multiple keys and store the result in the destination key

@param operation

The bitwise operation to perform: AND, OR, XOR, or (Redis 8.2+) DIFF, DIFF1, ANDOR, ONE

@param destkey

The destination key to store the result

@param key

The first source key

@param moreKeys

Additional source keys

@returns

Promise that resolves with the size of the string stored in the destination key

await redis.set("key1", "foobar");
await redis.set("key2", "abcdef");
await redis.bitop("AND", "dest", "key1", "key2");

Referenced types

type KeyLike = string | ArrayBufferView | Blob