You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Bloom commands (#1786)
* ft.alter * bloom commands * tdigest * delete tdigest * uncomment tests * small changes * Update MADD.ts * small changes * clean code * Update README.md * Update README.md Co-authored-by: leibale <leibale1998@gmail.com>
This commit is contained in:
19
packages/bloom/lib/commands/cuckoo/ADD.spec.ts
Normal file
19
packages/bloom/lib/commands/cuckoo/ADD.spec.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import { transformArguments, transformReply } from './ADD';
|
||||
|
||||
describe('CF ADD', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'item'),
|
||||
['CF.ADD', 'key', 'item']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.cf.add', async client => {
|
||||
assert.equal(
|
||||
await client.cf.add('key', 'item'),
|
||||
true
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
7
packages/bloom/lib/commands/cuckoo/ADD.ts
Normal file
7
packages/bloom/lib/commands/cuckoo/ADD.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, item: string): Array<string> {
|
||||
return ['CF.ADD', key, item];
|
||||
}
|
||||
|
||||
export { transformBooleanReply as transformReply } from '@node-redis/client/dist/lib/commands/generic-transformers';
|
21
packages/bloom/lib/commands/cuckoo/ADDNX.spec.ts
Normal file
21
packages/bloom/lib/commands/cuckoo/ADDNX.spec.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import { transformArguments } from './ADDNX';
|
||||
|
||||
describe('CF ADDNX', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('basic add', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'item'),
|
||||
['CF.ADDNX', 'key', 'item']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.cf.add', async client => {
|
||||
assert.equal(
|
||||
await client.cf.addNX('key', 'item'),
|
||||
true
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
7
packages/bloom/lib/commands/cuckoo/ADDNX.ts
Normal file
7
packages/bloom/lib/commands/cuckoo/ADDNX.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, item: string): Array<string> {
|
||||
return ['CF.ADDNX', key, item];
|
||||
}
|
||||
|
||||
export { transformBooleanReply as transformReply } from '@node-redis/client/dist/lib/commands/generic-transformers';
|
19
packages/bloom/lib/commands/cuckoo/COUNT.spec.ts
Normal file
19
packages/bloom/lib/commands/cuckoo/COUNT.spec.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import { transformArguments } from './COUNT';
|
||||
|
||||
describe('CF COUNT', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'item'),
|
||||
['CF.COUNT', 'key', 'item']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.cf.count', async client => {
|
||||
assert.equal(
|
||||
await client.cf.count('key', 'item'),
|
||||
0
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
7
packages/bloom/lib/commands/cuckoo/COUNT.ts
Normal file
7
packages/bloom/lib/commands/cuckoo/COUNT.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, item: string): Array<string> {
|
||||
return ['CF.COUNT', key, item];
|
||||
}
|
||||
|
||||
export declare function transformReply(): number;
|
21
packages/bloom/lib/commands/cuckoo/DEL.spec.ts
Normal file
21
packages/bloom/lib/commands/cuckoo/DEL.spec.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import { transformArguments } from './DEL';
|
||||
|
||||
describe('CF DEL', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'item'),
|
||||
['CF.DEL', 'key', 'item']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.cf.del', async client => {
|
||||
await client.cf.reserve('key', 4);
|
||||
|
||||
assert.equal(
|
||||
await client.cf.del('key', 'item'),
|
||||
false
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
7
packages/bloom/lib/commands/cuckoo/DEL.ts
Normal file
7
packages/bloom/lib/commands/cuckoo/DEL.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, item: string): Array<string> {
|
||||
return ['CF.DEL', key, item];
|
||||
}
|
||||
|
||||
export { transformBooleanReply as transformReply } from '@node-redis/client/dist/lib/commands/generic-transformers';
|
19
packages/bloom/lib/commands/cuckoo/EXISTS.spec.ts
Normal file
19
packages/bloom/lib/commands/cuckoo/EXISTS.spec.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import { transformArguments } from './EXISTS';
|
||||
|
||||
describe('CF EXISTS', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'item'),
|
||||
['CF.EXISTS', 'key', 'item']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.cf.exists', async client => {
|
||||
assert.equal(
|
||||
await client.cf.exists('key', 'item'),
|
||||
false
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
9
packages/bloom/lib/commands/cuckoo/EXISTS.ts
Normal file
9
packages/bloom/lib/commands/cuckoo/EXISTS.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string, item: string): Array<string> {
|
||||
return ['CF.EXISTS', key, item];
|
||||
}
|
||||
|
||||
export { transformBooleanReply as transformReply } from '@node-redis/client/dist/lib/commands/generic-transformers';
|
27
packages/bloom/lib/commands/cuckoo/INFO.spec.ts
Normal file
27
packages/bloom/lib/commands/cuckoo/INFO.spec.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import { transformArguments } from './INFO';
|
||||
|
||||
describe('CF INFO', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('cuckoo'),
|
||||
['CF.INFO', 'cuckoo']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.cf.info', async client => {
|
||||
await client.cf.reserve('key', 4);
|
||||
|
||||
const info = await client.cf.info('key');
|
||||
assert.equal(typeof info, 'object');
|
||||
assert.equal(typeof info.size, 'number');
|
||||
assert.equal(typeof info.numberOfBuckets, 'number');
|
||||
assert.equal(typeof info.numberOfFilters, 'number');
|
||||
assert.equal(typeof info.numberOfInsertedItems, 'number');
|
||||
assert.equal(typeof info.numberOfDeletedItems, 'number');
|
||||
assert.equal(typeof info.bucketSize, 'number');
|
||||
assert.equal(typeof info.expansionRate, 'number');
|
||||
assert.equal(typeof info.maxIteration, 'number');
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
50
packages/bloom/lib/commands/cuckoo/INFO.ts
Normal file
50
packages/bloom/lib/commands/cuckoo/INFO.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string): Array<string> {
|
||||
return ['CF.INFO', key];
|
||||
}
|
||||
|
||||
export type InfoRawReply = [
|
||||
_: string,
|
||||
size: number,
|
||||
_: string,
|
||||
numberOfBuckets: number,
|
||||
_: string,
|
||||
numberOfFilters: number,
|
||||
_: string,
|
||||
numberOfInsertedItems: number,
|
||||
_: string,
|
||||
numberOfDeletedItems: number,
|
||||
_: string,
|
||||
bucketSize: number,
|
||||
_: string,
|
||||
expansionRate: number,
|
||||
_: string,
|
||||
maxIteration: number
|
||||
];
|
||||
|
||||
export interface InfoReply {
|
||||
size: number;
|
||||
numberOfBuckets: number;
|
||||
numberOfFilters: number;
|
||||
numberOfInsertedItems: number;
|
||||
numberOfDeletedItems: number;
|
||||
bucketSize: number;
|
||||
expansionRate: number;
|
||||
maxIteration: number;
|
||||
}
|
||||
|
||||
export function transformReply(reply: InfoRawReply): InfoReply {
|
||||
return {
|
||||
size: reply[1],
|
||||
numberOfBuckets: reply[3],
|
||||
numberOfFilters: reply[5],
|
||||
numberOfInsertedItems: reply[7],
|
||||
numberOfDeletedItems: reply[9],
|
||||
bucketSize: reply[11],
|
||||
expansionRate: reply[13],
|
||||
maxIteration: reply[15]
|
||||
};
|
||||
}
|
22
packages/bloom/lib/commands/cuckoo/INSERT.spec.ts
Normal file
22
packages/bloom/lib/commands/cuckoo/INSERT.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import { transformArguments } from './INSERT';
|
||||
|
||||
describe('CF INSERT', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'item', {
|
||||
CAPACITY: 100,
|
||||
NOCREATE: true
|
||||
}),
|
||||
['CF.INSERT', 'key', 'CAPACITY', '100', 'NOCREATE', 'ITEMS', 'item']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.cf.insert', async client => {
|
||||
assert.deepEqual(
|
||||
await client.cf.insert('key', 'item'),
|
||||
[true]
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
18
packages/bloom/lib/commands/cuckoo/INSERT.ts
Normal file
18
packages/bloom/lib/commands/cuckoo/INSERT.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { RedisCommandArguments } from '@node-redis/client/dist/lib/commands';
|
||||
import { InsertOptions, pushInsertOptions } from ".";
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(
|
||||
key: string,
|
||||
items: string | Array<string>,
|
||||
options?: InsertOptions
|
||||
): RedisCommandArguments {
|
||||
return pushInsertOptions(
|
||||
['CF.INSERT', key],
|
||||
items,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
export { transformBooleanArrayReply as transformReply } from '@node-redis/client/dist/lib/commands/generic-transformers';
|
22
packages/bloom/lib/commands/cuckoo/INSERTNX.spec.ts
Normal file
22
packages/bloom/lib/commands/cuckoo/INSERTNX.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import { transformArguments } from './INSERTNX';
|
||||
|
||||
describe('CF INSERTNX', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'item', {
|
||||
CAPACITY: 100,
|
||||
NOCREATE: true
|
||||
}),
|
||||
['CF.INSERTNX', 'key', 'CAPACITY', '100', 'NOCREATE', 'ITEMS', 'item']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.cf.insertnx', async client => {
|
||||
assert.deepEqual(
|
||||
await client.cf.insertNX('key', 'item'),
|
||||
[true]
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
18
packages/bloom/lib/commands/cuckoo/INSERTNX.ts
Normal file
18
packages/bloom/lib/commands/cuckoo/INSERTNX.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { RedisCommandArguments } from '@node-redis/client/dist/lib/commands';
|
||||
import { InsertOptions, pushInsertOptions } from ".";
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(
|
||||
key: string,
|
||||
items: string | Array<string>,
|
||||
options?: InsertOptions
|
||||
): RedisCommandArguments {
|
||||
return pushInsertOptions(
|
||||
['CF.INSERTNX', key],
|
||||
items,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
export { transformBooleanArrayReply as transformReply } from '@node-redis/client/dist/lib/commands/generic-transformers';
|
11
packages/bloom/lib/commands/cuckoo/LOADCHUNK.spec.ts
Normal file
11
packages/bloom/lib/commands/cuckoo/LOADCHUNK.spec.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { transformArguments } from './LOADCHUNK';
|
||||
|
||||
describe('CF LOADCHUNK', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('item', 0, ''),
|
||||
['CF.LOADCHUNK', 'item', '0', '']
|
||||
);
|
||||
});
|
||||
});
|
7
packages/bloom/lib/commands/cuckoo/LOADCHUNK.ts
Normal file
7
packages/bloom/lib/commands/cuckoo/LOADCHUNK.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, iterator: number, chunk: string): Array<string> {
|
||||
return ['CF.LOADCHUNK', key, iterator.toString(), chunk];
|
||||
}
|
||||
|
||||
export declare function transformReply(): 'OK';
|
48
packages/bloom/lib/commands/cuckoo/RESERVE.spec.ts
Normal file
48
packages/bloom/lib/commands/cuckoo/RESERVE.spec.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../../test-utils';
|
||||
import { transformArguments } from './RESERVE';
|
||||
|
||||
describe('CF RESERVE', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('simple', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 4),
|
||||
['CF.RESERVE', 'key', '4']
|
||||
);
|
||||
});
|
||||
|
||||
it('with EXPANSION', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 4, {
|
||||
EXPANSION: 1
|
||||
}),
|
||||
['CF.RESERVE', 'key', '4', 'EXPANSION', '1']
|
||||
);
|
||||
});
|
||||
|
||||
it('with BUCKETSIZE', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 4, {
|
||||
BUCKETSIZE: 2
|
||||
}),
|
||||
['CF.RESERVE', 'key', '4', 'BUCKETSIZE', '2']
|
||||
);
|
||||
});
|
||||
|
||||
it('with MAXITERATIONS', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 4, {
|
||||
MAXITERATIONS: 1
|
||||
}),
|
||||
['CF.RESERVE', 'key', '4', 'MAXITERATIONS', '1']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.cf.reserve', async client => {
|
||||
assert.equal(
|
||||
await client.cf.reserve('key', 4),
|
||||
'OK'
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
31
packages/bloom/lib/commands/cuckoo/RESERVE.ts
Normal file
31
packages/bloom/lib/commands/cuckoo/RESERVE.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
interface ReserveOptions {
|
||||
BUCKETSIZE?: number;
|
||||
MAXITERATIONS?: number;
|
||||
EXPANSION?: number;
|
||||
}
|
||||
|
||||
export function transformArguments(
|
||||
key: string,
|
||||
capacity: number,
|
||||
options?: ReserveOptions
|
||||
): Array<string> {
|
||||
const args = ['CF.RESERVE', key, capacity.toString()];
|
||||
|
||||
if (options?.BUCKETSIZE) {
|
||||
args.push('BUCKETSIZE', options.BUCKETSIZE.toString());
|
||||
}
|
||||
|
||||
if (options?.MAXITERATIONS) {
|
||||
args.push('MAXITERATIONS', options.MAXITERATIONS.toString());
|
||||
}
|
||||
|
||||
if (options?.EXPANSION) {
|
||||
args.push('EXPANSION', options.EXPANSION.toString());
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
export declare function transformReply(): 'OK';
|
11
packages/bloom/lib/commands/cuckoo/SCANDUMP.spec.ts
Normal file
11
packages/bloom/lib/commands/cuckoo/SCANDUMP.spec.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { transformArguments } from './SCANDUMP';
|
||||
|
||||
describe('CF SCANDUMP', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 0),
|
||||
['CF.SCANDUMP', 'key', '0']
|
||||
);
|
||||
});
|
||||
});
|
22
packages/bloom/lib/commands/cuckoo/SCANDUMP.ts
Normal file
22
packages/bloom/lib/commands/cuckoo/SCANDUMP.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, iterator: number): Array<string> {
|
||||
return ['CF.SCANDUMP', key, iterator.toString()];
|
||||
}
|
||||
|
||||
type ScanDumpRawReply = [
|
||||
iterator: number,
|
||||
chunk: string
|
||||
];
|
||||
|
||||
interface ScanDumpReply {
|
||||
iterator: number;
|
||||
chunk: string;
|
||||
}
|
||||
|
||||
export function transformReply([iterator, chunk]: ScanDumpRawReply): ScanDumpReply {
|
||||
return {
|
||||
iterator,
|
||||
chunk
|
||||
};
|
||||
}
|
48
packages/bloom/lib/commands/cuckoo/index.spec.ts
Normal file
48
packages/bloom/lib/commands/cuckoo/index.spec.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { pushInsertOptions } from '.';
|
||||
|
||||
describe('pushInsertOptions', () => {
|
||||
describe('single item', () => {
|
||||
it('single item', () => {
|
||||
assert.deepEqual(
|
||||
pushInsertOptions([], 'item'),
|
||||
['ITEMS', 'item']
|
||||
);
|
||||
});
|
||||
|
||||
it('multiple items', () => {
|
||||
assert.deepEqual(
|
||||
pushInsertOptions([], ['1', '2']),
|
||||
['ITEMS', '1', '2']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('with CAPACITY', () => {
|
||||
assert.deepEqual(
|
||||
pushInsertOptions([], 'item', {
|
||||
CAPACITY: 100
|
||||
}),
|
||||
['CAPACITY', '100', 'ITEMS', 'item']
|
||||
);
|
||||
});
|
||||
|
||||
it('with NOCREATE', () => {
|
||||
assert.deepEqual(
|
||||
pushInsertOptions([], 'item', {
|
||||
NOCREATE: true
|
||||
}),
|
||||
['NOCREATE', 'ITEMS', 'item']
|
||||
);
|
||||
});
|
||||
|
||||
it('with CAPACITY and NOCREATE', () => {
|
||||
assert.deepEqual(
|
||||
pushInsertOptions([], 'item', {
|
||||
CAPACITY: 100,
|
||||
NOCREATE: true
|
||||
}),
|
||||
['CAPACITY', '100', 'NOCREATE', 'ITEMS', 'item']
|
||||
);
|
||||
});
|
||||
});
|
62
packages/bloom/lib/commands/cuckoo/index.ts
Normal file
62
packages/bloom/lib/commands/cuckoo/index.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
|
||||
import * as ADD from './ADD';
|
||||
import * as ADDNX from './ADDNX';
|
||||
import * as COUNT from './COUNT';
|
||||
import * as DEL from './DEL';
|
||||
import * as EXISTS from './EXISTS';
|
||||
import * as INFO from './INFO';
|
||||
import * as INSERT from './INSERT';
|
||||
import * as INSERTNX from './INSERTNX';
|
||||
import * as LOADCHUNK from './LOADCHUNK';
|
||||
import * as RESERVE from './RESERVE';
|
||||
import * as SCANDUMP from './SCANDUMP';
|
||||
import { pushVerdictArguments } from '@node-redis/client/lib/commands/generic-transformers';
|
||||
import { RedisCommandArguments } from '@node-redis/client/dist/lib/commands';
|
||||
|
||||
export default {
|
||||
ADD,
|
||||
add: ADD,
|
||||
ADDNX,
|
||||
addNX: ADDNX,
|
||||
COUNT,
|
||||
count: COUNT,
|
||||
DEL,
|
||||
del: DEL,
|
||||
EXISTS,
|
||||
exists: EXISTS,
|
||||
INFO,
|
||||
info: INFO,
|
||||
INSERT,
|
||||
insert: INSERT,
|
||||
INSERTNX,
|
||||
insertNX: INSERTNX,
|
||||
LOADCHUNK,
|
||||
loadChunk: LOADCHUNK,
|
||||
RESERVE,
|
||||
reserve: RESERVE,
|
||||
SCANDUMP,
|
||||
scanDump: SCANDUMP
|
||||
};
|
||||
|
||||
export interface InsertOptions {
|
||||
CAPACITY?: number;
|
||||
NOCREATE?: true;
|
||||
}
|
||||
|
||||
export function pushInsertOptions(
|
||||
args: RedisCommandArguments,
|
||||
items: string | Array<string>,
|
||||
options?: InsertOptions
|
||||
): RedisCommandArguments {
|
||||
if (options?.CAPACITY) {
|
||||
args.push('CAPACITY');
|
||||
args.push(options.CAPACITY.toString());
|
||||
}
|
||||
|
||||
if (options?.NOCREATE) {
|
||||
args.push('NOCREATE');
|
||||
}
|
||||
|
||||
args.push('ITEMS');
|
||||
return pushVerdictArguments(args, items);
|
||||
}
|
Reference in New Issue
Block a user