You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
some more commands
This commit is contained in:
@@ -1,41 +1,34 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import testUtils, { GLOBAL } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './LCS_IDX';
|
import LCS_IDX from './LCS_IDX';
|
||||||
|
|
||||||
describe('LCS_IDX', () => {
|
describe('LCS IDX', () => {
|
||||||
testUtils.isVersionGreaterThanHook([7]);
|
testUtils.isVersionGreaterThanHook([7]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('1', '2'),
|
LCS_IDX.transformArguments('1', '2'),
|
||||||
['LCS', '1', '2', 'IDX']
|
['LCS', '1', '2', 'IDX']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.lcsIdx', async client => {
|
testUtils.testWithClient('client.lcsIdx', async client => {
|
||||||
const [, reply] = await Promise.all([
|
const [, reply] = await Promise.all([
|
||||||
client.mSet({
|
client.mSet({
|
||||||
'1': 'abc',
|
'1': 'abc',
|
||||||
'2': 'bc'
|
'2': 'bc'
|
||||||
}),
|
}),
|
||||||
client.lcsIdx('1', '2')
|
client.lcsIdx('1', '2')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert.deepEqual(
|
console.log(reply);
|
||||||
reply,
|
|
||||||
{
|
assert.deepEqual(
|
||||||
matches: [{
|
reply,
|
||||||
key1: {
|
{
|
||||||
start: 1,
|
matches: [[[1, 2], [0, 1]]],
|
||||||
end: 2
|
len: 2
|
||||||
},
|
}
|
||||||
key2: {
|
);
|
||||||
start: 0,
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
end: 1
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
length: 2
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
|
||||||
});
|
});
|
||||||
|
@@ -1,48 +1,50 @@
|
|||||||
// import { RedisArgument, TuplesToMapReply, BlobStringReply, ArrayReply, NumberReply, Resp2Reply, Command, TuplesReply } from '../RESP/types';
|
import { RedisArgument, TuplesToMapReply, BlobStringReply, ArrayReply, NumberReply, Resp2Reply, Command, TuplesReply } from '../RESP/types';
|
||||||
// import LCS from './LCS';
|
import LCS from './LCS';
|
||||||
|
|
||||||
// export interface LcsIdxOptions {
|
export interface LcsIdxOptions {
|
||||||
// MINMATCHLEN?: number;
|
MINMATCHLEN?: number;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// export type LcsIdxRange = TuplesReply<[
|
export type LcsIdxRange = TuplesReply<[
|
||||||
// start: NumberReply,
|
start: NumberReply,
|
||||||
// end: NumberReply
|
end: NumberReply
|
||||||
// ]>;
|
]>;
|
||||||
|
|
||||||
// export type LcsIdxMatches = ArrayReply<
|
export type LcsIdxMatches = ArrayReply<
|
||||||
// TuplesReply<[
|
TuplesReply<[
|
||||||
// key1: LcsIdxRange,
|
key1: LcsIdxRange,
|
||||||
// key2: LcsIdxRange
|
key2: LcsIdxRange
|
||||||
// ]>
|
]>
|
||||||
// >;
|
>;
|
||||||
|
|
||||||
// export type LcsIdxReply = TuplesToMapReply<[
|
export type LcsIdxReply = TuplesToMapReply<[
|
||||||
// [BlobStringReply<'matches'>, LcsIdxMatches],
|
[BlobStringReply<'matches'>, LcsIdxMatches],
|
||||||
// [BlobStringReply<'len'>, NumberReply]
|
[BlobStringReply<'len'>, NumberReply]
|
||||||
// ]>;
|
]>;
|
||||||
|
|
||||||
// export default {
|
export default {
|
||||||
// FIRST_KEY_INDEX: LCS.FIRST_KEY_INDEX,
|
FIRST_KEY_INDEX: LCS.FIRST_KEY_INDEX,
|
||||||
// IS_READ_ONLY: LCS.IS_READ_ONLY,
|
IS_READ_ONLY: LCS.IS_READ_ONLY,
|
||||||
// transformArguments(
|
transformArguments(
|
||||||
// key1: RedisArgument,
|
key1: RedisArgument,
|
||||||
// key2: RedisArgument,
|
key2: RedisArgument,
|
||||||
// options?: LcsIdxOptions
|
options?: LcsIdxOptions
|
||||||
// ) {
|
) {
|
||||||
// const args = LCS.transformArguments(key1, key2);
|
const args = LCS.transformArguments(key1, key2);
|
||||||
|
|
||||||
// if (options?.MINMATCHLEN) {
|
args.push('IDX');
|
||||||
// args.push('MINMATCHLEN', options.MINMATCHLEN.toString());
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return args;
|
if (options?.MINMATCHLEN) {
|
||||||
// },
|
args.push('MINMATCHLEN', options.MINMATCHLEN.toString());
|
||||||
// transformReply: {
|
}
|
||||||
// 2: (reply: Resp2Reply<LcsIdxReply>) => ({
|
|
||||||
// matches: reply[1],
|
return args;
|
||||||
// len: reply[2]
|
},
|
||||||
// }),
|
transformReply: {
|
||||||
// 3: undefined as unknown as () => LcsIdxReply
|
2: (reply: Resp2Reply<LcsIdxReply>) => ({
|
||||||
// }
|
matches: reply[1],
|
||||||
// } as const satisfies Command;
|
len: reply[3]
|
||||||
|
}),
|
||||||
|
3: undefined as unknown as () => LcsIdxReply
|
||||||
|
}
|
||||||
|
} as const satisfies Command;
|
||||||
|
@@ -1,42 +1,35 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import testUtils, { GLOBAL } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './LCS_IDX_WITHMATCHLEN';
|
import LCS_IDX_WITHMATCHLEN from './LCS_IDX_WITHMATCHLEN';
|
||||||
|
|
||||||
describe('LCS_IDX_WITHMATCHLEN', () => {
|
describe('LCS IDX WITHMATCHLEN', () => {
|
||||||
testUtils.isVersionGreaterThanHook([7]);
|
testUtils.isVersionGreaterThanHook([7]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('1', '2'),
|
LCS_IDX_WITHMATCHLEN.transformArguments('1', '2'),
|
||||||
['LCS', '1', '2', 'IDX', 'WITHMATCHLEN']
|
['LCS', '1', '2', 'IDX', 'WITHMATCHLEN']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.lcsIdxWithMatchLen', async client => {
|
testUtils.testWithClient('client.lcsIdxWithMatchLen', async client => {
|
||||||
const [, reply] = await Promise.all([
|
const [, reply] = await Promise.all([
|
||||||
client.mSet({
|
client.mSet({
|
||||||
'1': 'abc',
|
'1': 'abc',
|
||||||
'2': 'bc'
|
'2': 'bc'
|
||||||
}),
|
}),
|
||||||
client.lcsIdxWithMatchLen('1', '2')
|
client.lcsIdxWithMatchLen('1', '2')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
reply,
|
reply,
|
||||||
{
|
{
|
||||||
matches: [{
|
matches: [
|
||||||
key1: {
|
[[[1, 2], [0, 1]]],
|
||||||
start: 1,
|
2
|
||||||
end: 2
|
],
|
||||||
},
|
len: 2
|
||||||
key2: {
|
}
|
||||||
start: 0,
|
);
|
||||||
end: 1
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
},
|
|
||||||
length: 2
|
|
||||||
}],
|
|
||||||
length: 2
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
|
||||||
});
|
});
|
||||||
|
@@ -1,47 +1,36 @@
|
|||||||
// import { RedisArgument, TuplesToMapReply, BlobStringReply, ArrayReply, NumberReply, Resp2Reply, Command, TuplesReply } from '../RESP/types';
|
import { RedisArgument, TuplesToMapReply, BlobStringReply, ArrayReply, NumberReply, Resp2Reply, Command, TuplesReply } from '../RESP/types';
|
||||||
// import LCS from './LCS';
|
import LCS_IDX, { LcsIdxOptions, LcsIdxRange } from './LCS_IDX';
|
||||||
// import { LcsIdxRange } from './LCS_IDX';
|
|
||||||
|
|
||||||
// interface LcsIdxOptions {
|
export type LcsIdxWithMatchLenMatches = ArrayReply<
|
||||||
// MINMATCHLEN?: number;
|
TuplesReply<[
|
||||||
// }
|
key1: LcsIdxRange,
|
||||||
|
key2: LcsIdxRange,
|
||||||
|
len: NumberReply
|
||||||
|
]>
|
||||||
|
>;
|
||||||
|
|
||||||
// export type LcsIdxWithMatchLenMatches = ArrayReply<
|
export type LcsIdxWithMatchLenReply = TuplesToMapReply<[
|
||||||
// TuplesReply<[
|
[BlobStringReply<'matches'>, LcsIdxWithMatchLenMatches],
|
||||||
// key1: LcsIdxRange,
|
[BlobStringReply<'len'>, NumberReply]
|
||||||
// key2: LcsIdxRange,
|
]>;
|
||||||
// len: NumberReply
|
|
||||||
// ]>
|
|
||||||
// >;
|
|
||||||
|
|
||||||
// export type LcsIdxReply = TuplesToMapReply<[
|
export default {
|
||||||
// [BlobStringReply<'matches'>, LcsIdxWithMatchLenMatches],
|
FIRST_KEY_INDEX: LCS_IDX.FIRST_KEY_INDEX,
|
||||||
// [BlobStringReply<'len'>, NumberReply]
|
IS_READ_ONLY: LCS_IDX.IS_READ_ONLY,
|
||||||
// ]>;
|
transformArguments(
|
||||||
|
key1: RedisArgument,
|
||||||
// export default {
|
key2: RedisArgument,
|
||||||
// FIRST_KEY_INDEX: LCS.FIRST_KEY_INDEX,
|
options?: LcsIdxOptions
|
||||||
// IS_READ_ONLY: LCS.IS_READ_ONLY,
|
) {
|
||||||
// transformArguments(
|
const args = LCS_IDX.transformArguments(key1, key2);
|
||||||
// key1: RedisArgument,
|
args.push('WITHMATCHLEN');
|
||||||
// key2: RedisArgument,
|
return args;
|
||||||
// options?: LcsIdxOptions
|
},
|
||||||
// ) {
|
transformReply: {
|
||||||
// const args = LCS.transformArguments(key1, key2);
|
2: (reply: Resp2Reply<LcsIdxWithMatchLenReply>) => ({
|
||||||
|
matches: reply[1],
|
||||||
// if (options?.MINMATCHLEN) {
|
len: reply[3]
|
||||||
// args.push('MINMATCHLEN', options.MINMATCHLEN.toString());
|
}),
|
||||||
// }
|
3: undefined as unknown as () => LcsIdxWithMatchLenReply
|
||||||
|
}
|
||||||
// args.push('WITHMATCHLEN');
|
} as const satisfies Command;
|
||||||
|
|
||||||
// return args;
|
|
||||||
// },
|
|
||||||
// transformReply: {
|
|
||||||
// 2: (reply: Resp2Reply<LcsIdxReply>) => ({
|
|
||||||
// matches: reply[1],
|
|
||||||
// len: reply[2]
|
|
||||||
// }),
|
|
||||||
// 3: undefined as unknown as () => LcsIdxReply
|
|
||||||
// }
|
|
||||||
// } as const satisfies Command;
|
|
||||||
|
@@ -1,35 +1,35 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import testUtils, { GLOBAL } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './LOLWUT';
|
import LOLWUT from './LOLWUT';
|
||||||
|
|
||||||
describe('LOLWUT', () => {
|
describe('LOLWUT', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments(),
|
LOLWUT.transformArguments(),
|
||||||
['LOLWUT']
|
['LOLWUT']
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
it('with version', () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments(5),
|
|
||||||
['LOLWUT', 'VERSION', '5']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('with version and optional arguments', () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments(5, 1, 2, 3),
|
|
||||||
['LOLWUT', 'VERSION', '5', '1', '2', '3']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.LOLWUT', async client => {
|
it('with version', () => {
|
||||||
assert.equal(
|
assert.deepEqual(
|
||||||
typeof (await client.LOLWUT()),
|
LOLWUT.transformArguments(5),
|
||||||
'string'
|
['LOLWUT', 'VERSION', '5']
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
});
|
||||||
|
|
||||||
|
it('with version and optional arguments', () => {
|
||||||
|
assert.deepEqual(
|
||||||
|
LOLWUT.transformArguments(5, 1, 2, 3),
|
||||||
|
['LOLWUT', 'VERSION', '5', '1', '2', '3']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
testUtils.testWithClient('client.LOLWUT', async client => {
|
||||||
|
assert.equal(
|
||||||
|
typeof (await client.LOLWUT()),
|
||||||
|
'string'
|
||||||
|
);
|
||||||
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,19 +1,19 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import testUtils, { GLOBAL } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './MEMORY_DOCTOR';
|
import MEMORY_DOCTOR from './MEMORY_DOCTOR';
|
||||||
|
|
||||||
describe('MEMORY DOCTOR', () => {
|
describe('MEMORY DOCTOR', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments(),
|
MEMORY_DOCTOR.transformArguments(),
|
||||||
['MEMORY', 'DOCTOR']
|
['MEMORY', 'DOCTOR']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.memoryDoctor', async client => {
|
testUtils.testWithClient('client.memoryDoctor', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
typeof (await client.memoryDoctor()),
|
typeof (await client.memoryDoctor()),
|
||||||
'string'
|
'string'
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,10 @@
|
|||||||
export function transformArguments(): Array<string> {
|
import { BlobStringReply, Command } from '../RESP/types';
|
||||||
return ['MEMORY', 'DOCTOR'];
|
|
||||||
}
|
|
||||||
|
|
||||||
export declare function transformReply(): string;
|
export default {
|
||||||
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
|
transformArguments() {
|
||||||
|
return ['MEMORY', 'DOCTOR'];
|
||||||
|
},
|
||||||
|
transformReply: undefined as unknown as () => BlobStringReply
|
||||||
|
} as const satisfies Command;
|
||||||
|
@@ -1,19 +1,19 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import testUtils, { GLOBAL } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './MEMORY_MALLOC-STATS';
|
import MEMORY_MALLOC_STATS from './MEMORY_MALLOC-STATS';
|
||||||
|
|
||||||
describe('MEMORY MALLOC-STATS', () => {
|
describe('MEMORY MALLOC-STATS', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments(),
|
MEMORY_MALLOC_STATS.transformArguments(),
|
||||||
['MEMORY', 'MALLOC-STATS']
|
['MEMORY', 'MALLOC-STATS']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.memoryMallocStats', async client => {
|
testUtils.testWithClient('client.memoryMallocStats', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
typeof (await client.memoryDoctor()),
|
typeof (await client.memoryMallocStats()),
|
||||||
'string'
|
'string'
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,11 @@
|
|||||||
export function transformArguments(): Array<string> {
|
import { BlobStringReply, Command } from '../RESP/types';
|
||||||
return ['MEMORY', 'MALLOC-STATS'];
|
|
||||||
}
|
export default {
|
||||||
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
|
transformArguments() {
|
||||||
|
return ['MEMORY', 'MALLOC-STATS'];
|
||||||
|
},
|
||||||
|
transformReply: undefined as unknown as () => BlobStringReply
|
||||||
|
} as const satisfies Command;
|
||||||
|
|
||||||
export declare function transformReply(): string;
|
|
||||||
|
@@ -1,19 +1,19 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import testUtils, { GLOBAL } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './MEMORY_PURGE';
|
import MEMORY_PURGE from './MEMORY_PURGE';
|
||||||
|
|
||||||
describe('MEMORY PURGE', () => {
|
describe('MEMORY PURGE', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments(),
|
MEMORY_PURGE.transformArguments(),
|
||||||
['MEMORY', 'PURGE']
|
['MEMORY', 'PURGE']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.memoryPurge', async client => {
|
testUtils.testWithClient('client.memoryPurge', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.memoryPurge(),
|
await client.memoryPurge(),
|
||||||
'OK'
|
'OK'
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,11 @@
|
|||||||
export function transformArguments(): Array<string> {
|
import { SimpleStringReply, Command } from '../RESP/types';
|
||||||
return ['MEMORY', 'PURGE'];
|
|
||||||
}
|
export default {
|
||||||
|
FIRST_KEY_INDEX: undefined,
|
||||||
|
IS_READ_ONLY: false,
|
||||||
|
transformArguments() {
|
||||||
|
return ['MEMORY', 'PURGE'];
|
||||||
|
},
|
||||||
|
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||||
|
} as const satisfies Command;
|
||||||
|
|
||||||
export declare function transformReply(): string;
|
|
||||||
|
@@ -1,108 +1,43 @@
|
|||||||
import { strict as assert } from 'assert';
|
// import { strict as assert } from 'assert';
|
||||||
import { transformArguments, transformReply } from './MEMORY_STATS';
|
// import testUtils, { GLOBAL } from '../test-utils';
|
||||||
|
// import MEMORY_STATS from './MEMORY_STATS';
|
||||||
|
|
||||||
describe('MEMORY STATS', () => {
|
// describe('MEMORY STATS', () => {
|
||||||
it('transformArguments', () => {
|
// it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
// assert.deepEqual(
|
||||||
transformArguments(),
|
// MEMORY_STATS.transformArguments(),
|
||||||
['MEMORY', 'STATS']
|
// ['MEMORY', 'STATS']
|
||||||
);
|
// );
|
||||||
});
|
// });
|
||||||
|
|
||||||
it('transformReply', () => {
|
// testUtils.testWithClient('client.memoryStats', async client => {
|
||||||
assert.deepEqual(
|
// const memoryStats = await client.memoryStats();
|
||||||
transformReply([
|
// assert.equal(typeof memoryStats['peak.allocated'], 'number');
|
||||||
'peak.allocated',
|
// assert.equal(typeof memoryStats['total.allocated'], 'number');
|
||||||
952728,
|
// assert.equal(typeof memoryStats['startup.allocated'], 'number');
|
||||||
'total.allocated',
|
// assert.equal(typeof memoryStats['replication.backlog'], 'number');
|
||||||
892904,
|
// assert.equal(typeof memoryStats['clients.slaves'], 'number');
|
||||||
'startup.allocated',
|
// assert.equal(typeof memoryStats['clients.normal'], 'number');
|
||||||
809952,
|
// assert.equal(typeof memoryStats['cluster.links'], 'number');
|
||||||
'replication.backlog',
|
// assert.equal(typeof memoryStats['aof.buffer'], 'number');
|
||||||
0,
|
// assert.equal(typeof memoryStats['lua.caches'], 'number');
|
||||||
'clients.slaves',
|
// assert.equal(typeof memoryStats['functions.caches'], 'number');
|
||||||
0,
|
// assert.equal(typeof memoryStats['overhead.total'], 'number');
|
||||||
'clients.normal',
|
// assert.equal(typeof memoryStats['keys.count'], 'number');
|
||||||
41000,
|
// assert.equal(typeof memoryStats['keys.bytes-per-key'], 'number');
|
||||||
'aof.buffer',
|
// assert.equal(typeof memoryStats['dataset.bytes'], 'number');
|
||||||
0,
|
// assert.equal(typeof memoryStats['dataset.percentage'], 'string');
|
||||||
'lua.caches',
|
// assert.equal(typeof memoryStats['peak.percentage'], 'string');
|
||||||
0,
|
// assert.equal(typeof memoryStats['allocator.allocated'], 'number');
|
||||||
'db.0',
|
// assert.equal(typeof memoryStats['allocator.active'], 'number');
|
||||||
[
|
// assert.equal(typeof memoryStats['allocator.resident'], 'number');
|
||||||
'overhead.hashtable.main',
|
// assert.equal(typeof memoryStats['allocator-fragmentation.ratio'], 'string');
|
||||||
72,
|
// assert.equal(typeof memoryStats['allocator-fragmentation.bytes'], 'number');
|
||||||
'overhead.hashtable.expires',
|
// assert.equal(typeof memoryStats['allocator-rss.ratio'], 'string');
|
||||||
0
|
// assert.equal(typeof memoryStats['allocator-rss.bytes'], 'number');
|
||||||
],
|
// assert.equal(typeof memoryStats['rss-overhead.ratio'], 'string');
|
||||||
'overhead.total',
|
// assert.equal(typeof memoryStats['rss-overhead.bytes'], 'number');
|
||||||
850952,
|
// assert.equal(typeof memoryStats['fragmentation'], 'string');
|
||||||
'keys.count',
|
// assert.equal(typeof memoryStats['fragmentation.bytes'], 'number');
|
||||||
0,
|
// }, GLOBAL.SERVERS.OPEN);
|
||||||
'keys.bytes-per-key',
|
// });
|
||||||
0,
|
|
||||||
'dataset.bytes',
|
|
||||||
41952,
|
|
||||||
'dataset.percentage',
|
|
||||||
'50.573825836181641',
|
|
||||||
'peak.percentage',
|
|
||||||
'93.720771789550781',
|
|
||||||
'allocator.allocated',
|
|
||||||
937632,
|
|
||||||
'allocator.active',
|
|
||||||
1191936,
|
|
||||||
'allocator.resident',
|
|
||||||
4005888,
|
|
||||||
'allocator-fragmentation.ratio',
|
|
||||||
'1.2712193727493286',
|
|
||||||
'allocator-fragmentation.bytes',
|
|
||||||
254304,
|
|
||||||
'allocator-rss.ratio',
|
|
||||||
'3.3608248233795166',
|
|
||||||
'allocator-rss.bytes',
|
|
||||||
2813952,
|
|
||||||
'rss-overhead.ratio',
|
|
||||||
'2.4488751888275146',
|
|
||||||
'rss-overhead.bytes',
|
|
||||||
5804032,
|
|
||||||
'fragmentation',
|
|
||||||
'11.515504837036133',
|
|
||||||
'fragmentation.bytes',
|
|
||||||
8958032
|
|
||||||
]),
|
|
||||||
{
|
|
||||||
peakAllocated: 952728,
|
|
||||||
totalAllocated: 892904,
|
|
||||||
startupAllocated: 809952,
|
|
||||||
replicationBacklog: 0,
|
|
||||||
clientsReplicas: 0,
|
|
||||||
clientsNormal: 41000,
|
|
||||||
aofBuffer: 0,
|
|
||||||
luaCaches: 0,
|
|
||||||
overheadTotal: 850952,
|
|
||||||
keysCount: 0,
|
|
||||||
keysBytesPerKey: 0,
|
|
||||||
datasetBytes: 41952,
|
|
||||||
datasetPercentage: 50.573825836181641,
|
|
||||||
peakPercentage: 93.720771789550781,
|
|
||||||
allocatorAllocated: 937632,
|
|
||||||
allocatorActive: 1191936,
|
|
||||||
allocatorResident: 4005888,
|
|
||||||
allocatorFragmentationRatio: 1.2712193727493286,
|
|
||||||
allocatorFragmentationBytes: 254304,
|
|
||||||
allocatorRssRatio: 3.3608248233795166,
|
|
||||||
allocatorRssBytes: 2813952,
|
|
||||||
rssOverheadRatio: 2.4488751888275146,
|
|
||||||
rssOverheadBytes: 5804032,
|
|
||||||
fragmentation: 11.515504837036133,
|
|
||||||
fragmentationBytes: 8958032,
|
|
||||||
db: {
|
|
||||||
0: {
|
|
||||||
overheadHashtableMain: 72,
|
|
||||||
overheadHashtableExpires: 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
@@ -1,93 +1,53 @@
|
|||||||
export function transformArguments(): Array<string> {
|
// import { TuplesToMapReply, BlobStringReply, NumberReply, DoubleReply, Command, Resp2Reply } from '../RESP/types';
|
||||||
return ['MEMORY', 'STATS'];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MemoryStatsReply {
|
// export type MemoryStatsReply = TuplesToMapReply<[
|
||||||
peakAllocated: number;
|
// [BlobStringReply<'peak.allocated'>, NumberReply],
|
||||||
totalAllocated: number;
|
// [BlobStringReply<'total.allocated'>, NumberReply],
|
||||||
startupAllocated: number;
|
// [BlobStringReply<'startup.allocated'>, NumberReply],
|
||||||
replicationBacklog: number;
|
// [BlobStringReply<'replication.backlog'>, NumberReply],
|
||||||
clientsReplicas: number;
|
// [BlobStringReply<'clients.slaves'>, NumberReply],
|
||||||
clientsNormal: number;
|
// [BlobStringReply<'clients.normal'>, NumberReply],
|
||||||
aofBuffer: number;
|
// [BlobStringReply<'cluster.links'>, NumberReply],
|
||||||
luaCaches: number;
|
// [BlobStringReply<'aof.buffer'>, NumberReply],
|
||||||
overheadTotal: number;
|
// [BlobStringReply<'lua.caches'>, NumberReply],
|
||||||
keysCount: number;
|
// [BlobStringReply<'functions.caches'>, NumberReply],
|
||||||
keysBytesPerKey: number;
|
// [BlobStringReply<'overhead.total'>, NumberReply],
|
||||||
datasetBytes: number;
|
// [BlobStringReply<'keys.count'>, NumberReply],
|
||||||
datasetPercentage: number;
|
// [BlobStringReply<'keys.bytes-per-key'>, NumberReply],
|
||||||
peakPercentage: number;
|
// [BlobStringReply<'dataset.bytes'>, NumberReply],
|
||||||
allocatorAllocated?: number,
|
// [BlobStringReply<'dataset.percentage'>, DoubleReply],
|
||||||
allocatorActive?: number;
|
// [BlobStringReply<'peak.percentage'>, DoubleReply],
|
||||||
allocatorResident?: number;
|
// [BlobStringReply<'allocator.allocated'>, NumberReply],
|
||||||
allocatorFragmentationRatio?: number;
|
// [BlobStringReply<'allocator.active'>, NumberReply],
|
||||||
allocatorFragmentationBytes?: number;
|
// [BlobStringReply<'allocator.resident'>, NumberReply],
|
||||||
allocatorRssRatio?: number;
|
// [BlobStringReply<'allocator-fragmentation.ratio'>, DoubleReply],
|
||||||
allocatorRssBytes?: number;
|
// [BlobStringReply<'allocator-fragmentation.bytes'>, NumberReply],
|
||||||
rssOverheadRatio?: number;
|
// [BlobStringReply<'allocator-rss.ratio'>, DoubleReply],
|
||||||
rssOverheadBytes?: number;
|
// [BlobStringReply<'allocator-rss.bytes'>, NumberReply],
|
||||||
fragmentation?: number;
|
// [BlobStringReply<'rss-overhead.ratio'>, DoubleReply],
|
||||||
fragmentationBytes: number;
|
// [BlobStringReply<'rss-overhead.bytes'>, NumberReply],
|
||||||
db: {
|
// [BlobStringReply<'fragmentation'>, DoubleReply],
|
||||||
[key: number]: {
|
// [BlobStringReply<'fragmentation.bytes'>, NumberReply]
|
||||||
overheadHashtableMain: number;
|
// ]>;
|
||||||
overheadHashtableExpires: number;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const FIELDS_MAPPING = {
|
// export default {
|
||||||
'peak.allocated': 'peakAllocated',
|
// FIRST_KEY_INDEX: undefined,
|
||||||
'total.allocated': 'totalAllocated',
|
// IS_READ_ONLY: true,
|
||||||
'startup.allocated': 'startupAllocated',
|
// transformArguments() {
|
||||||
'replication.backlog': 'replicationBacklog',
|
// return ['MEMORY', 'STATS'];
|
||||||
'clients.slaves': 'clientsReplicas',
|
// },
|
||||||
'clients.normal': 'clientsNormal',
|
// transformReply: {
|
||||||
'aof.buffer': 'aofBuffer',
|
// 2: (rawReply: Array<BlobStringReply | NumberReply>) => {
|
||||||
'lua.caches': 'luaCaches',
|
// const reply: Partial<Resp2Reply<MemoryStatsReply['DEFAULT']>> = {};
|
||||||
'overhead.total': 'overheadTotal',
|
|
||||||
'keys.count': 'keysCount',
|
|
||||||
'keys.bytes-per-key': 'keysBytesPerKey',
|
|
||||||
'dataset.bytes': 'datasetBytes',
|
|
||||||
'dataset.percentage': 'datasetPercentage',
|
|
||||||
'peak.percentage': 'peakPercentage',
|
|
||||||
'allocator.allocated': 'allocatorAllocated',
|
|
||||||
'allocator.active': 'allocatorActive',
|
|
||||||
'allocator.resident': 'allocatorResident',
|
|
||||||
'allocator-fragmentation.ratio': 'allocatorFragmentationRatio',
|
|
||||||
'allocator-fragmentation.bytes': 'allocatorFragmentationBytes',
|
|
||||||
'allocator-rss.ratio': 'allocatorRssRatio',
|
|
||||||
'allocator-rss.bytes': 'allocatorRssBytes',
|
|
||||||
'rss-overhead.ratio': 'rssOverheadRatio',
|
|
||||||
'rss-overhead.bytes': 'rssOverheadBytes',
|
|
||||||
'fragmentation': 'fragmentation',
|
|
||||||
'fragmentation.bytes': 'fragmentationBytes'
|
|
||||||
},
|
|
||||||
DB_FIELDS_MAPPING = {
|
|
||||||
'overhead.hashtable.main': 'overheadHashtableMain',
|
|
||||||
'overhead.hashtable.expires': 'overheadHashtableExpires'
|
|
||||||
};
|
|
||||||
|
|
||||||
export function transformReply(rawReply: Array<string | number | Array<string | number>>): MemoryStatsReply {
|
// let i = 0;
|
||||||
const reply: any = {
|
// while (i < rawReply.length) {
|
||||||
db: {}
|
// const key = rawReply[i++] as keyof MemoryStatsReply['DEFAULT'];
|
||||||
};
|
// reply[key] = rawReply[i++] as any;
|
||||||
|
// }
|
||||||
|
|
||||||
for (let i = 0; i < rawReply.length; i += 2) {
|
// return reply as MemoryStatsReply['DEFAULT'];
|
||||||
const key = rawReply[i] as string;
|
// },
|
||||||
if (key.startsWith('db.')) {
|
// 3: undefined as unknown as () => MemoryStatsReply
|
||||||
const dbTuples = rawReply[i + 1] as Array<string | number>,
|
// }
|
||||||
db: any = {};
|
// } as const satisfies Command;
|
||||||
for (let j = 0; j < dbTuples.length; j += 2) {
|
|
||||||
db[DB_FIELDS_MAPPING[dbTuples[j] as keyof typeof DB_FIELDS_MAPPING]] = dbTuples[j + 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
reply.db[key.substring(3)] = db;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
reply[FIELDS_MAPPING[key as keyof typeof FIELDS_MAPPING]] = Number(rawReply[i + 1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return reply as MemoryStatsReply;
|
|
||||||
}
|
|
||||||
|
@@ -1,30 +1,30 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import testUtils, { GLOBAL } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './MEMORY_USAGE';
|
import MEMORY_USAGE from './MEMORY_USAGE';
|
||||||
|
|
||||||
describe('MEMORY USAGE', () => {
|
describe('MEMORY USAGE', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key'),
|
MEMORY_USAGE.transformArguments('key'),
|
||||||
['MEMORY', 'USAGE', 'key']
|
['MEMORY', 'USAGE', 'key']
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
it('with SAMPLES', () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments('key', {
|
|
||||||
SAMPLES: 1
|
|
||||||
}),
|
|
||||||
['MEMORY', 'USAGE', 'key', 'SAMPLES', '1']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.memoryUsage', async client => {
|
it('with SAMPLES', () => {
|
||||||
assert.equal(
|
assert.deepEqual(
|
||||||
await client.memoryUsage('key'),
|
MEMORY_USAGE.transformArguments('key', {
|
||||||
null
|
SAMPLES: 1
|
||||||
);
|
}),
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
['MEMORY', 'USAGE', 'key', 'SAMPLES', '1']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
testUtils.testWithClient('client.memoryUsage', async client => {
|
||||||
|
assert.equal(
|
||||||
|
await client.memoryUsage('key'),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,19 +1,20 @@
|
|||||||
export const FIRST_KEY_INDEX = 1;
|
import { NumberReply, NullReply, Command, RedisArgument } from '../RESP/types';
|
||||||
|
|
||||||
export const IS_READ_ONLY = true;
|
export interface MemoryUsageOptions {
|
||||||
|
SAMPLES?: number;
|
||||||
interface MemoryUsageOptions {
|
|
||||||
SAMPLES?: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function transformArguments(key: string, options?: MemoryUsageOptions): Array<string> {
|
export default {
|
||||||
|
FIRST_KEY_INDEX: 1,
|
||||||
|
IS_READ_ONLY: true,
|
||||||
|
transformArguments(key: RedisArgument, options?: MemoryUsageOptions) {
|
||||||
const args = ['MEMORY', 'USAGE', key];
|
const args = ['MEMORY', 'USAGE', key];
|
||||||
|
|
||||||
if (options?.SAMPLES) {
|
if (options?.SAMPLES) {
|
||||||
args.push('SAMPLES', options.SAMPLES.toString());
|
args.push('SAMPLES', options.SAMPLES.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
}
|
},
|
||||||
|
transformReply: undefined as unknown as () => NumberReply | NullReply
|
||||||
export declare function transformReply(): number | null;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { transformArguments } from './MODULE_LIST';
|
import MODULE_LIST from './MODULE_LIST';
|
||||||
|
|
||||||
describe('MODULE LIST', () => {
|
describe('MODULE LIST', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments(),
|
MODULE_LIST.transformArguments(),
|
||||||
['MODULE', 'LIST']
|
['MODULE', 'LIST']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -2,7 +2,7 @@ import { ArrayReply, BlobStringReply, NumberReply, Command, Resp2Reply, TuplesTo
|
|||||||
|
|
||||||
export type ModuleListReply = ArrayReply<TuplesToMapReply<[
|
export type ModuleListReply = ArrayReply<TuplesToMapReply<[
|
||||||
[BlobStringReply<'name'>, BlobStringReply],
|
[BlobStringReply<'name'>, BlobStringReply],
|
||||||
[BlobStringReply<'version'>, NumberReply],
|
[BlobStringReply<'ver'>, NumberReply],
|
||||||
]>>;
|
]>>;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -15,7 +15,7 @@ export default {
|
|||||||
2: (reply: Resp2Reply<ModuleListReply>) => {
|
2: (reply: Resp2Reply<ModuleListReply>) => {
|
||||||
return reply.map(module => ({
|
return reply.map(module => ({
|
||||||
name: module[1],
|
name: module[1],
|
||||||
version: module[3]
|
ver: module[3]
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
3: undefined as unknown as () => ModuleListReply
|
3: undefined as unknown as () => ModuleListReply
|
||||||
|
@@ -1,20 +1,20 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { transformArguments } from './MODULE_LOAD';
|
import MODULE_LOAD from './MODULE_LOAD';
|
||||||
|
|
||||||
describe('MODULE LOAD', () => {
|
describe('MODULE LOAD', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('path'),
|
MODULE_LOAD.transformArguments('path'),
|
||||||
['MODULE', 'LOAD', 'path']
|
['MODULE', 'LOAD', 'path']
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
it('with module args', () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments('path', ['1', '2']),
|
|
||||||
['MODULE', 'LOAD', 'path', '1', '2']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('with module args', () => {
|
||||||
|
assert.deepEqual(
|
||||||
|
MODULE_LOAD.transformArguments('path', ['1', '2']),
|
||||||
|
['MODULE', 'LOAD', 'path', '1', '2']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -13,5 +13,5 @@ export default {
|
|||||||
|
|
||||||
return args;
|
return args;
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => SimpleStringReply
|
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { transformArguments } from './MODULE_UNLOAD';
|
import MODULE_UNLOAD from './MODULE_UNLOAD';
|
||||||
|
|
||||||
describe('MODULE UNLOAD', () => {
|
describe('MODULE UNLOAD', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('name'),
|
MODULE_UNLOAD.transformArguments('name'),
|
||||||
['MODULE', 'UNLOAD', 'name']
|
['MODULE', 'UNLOAD', 'name']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -6,5 +6,5 @@ export default {
|
|||||||
transformArguments(name: RedisArgument) {
|
transformArguments(name: RedisArgument) {
|
||||||
return ['MODULE', 'UNLOAD', name];
|
return ['MODULE', 'UNLOAD', name];
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => SimpleStringReply
|
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,28 +1,28 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import testUtils, { GLOBAL } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './PUBSUB_CHANNELS';
|
import PUBSUB_CHANNELS from './PUBSUB_CHANNELS';
|
||||||
|
|
||||||
describe('PUBSUB CHANNELS', () => {
|
describe('PUBSUB CHANNELS', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments(),
|
PUBSUB_CHANNELS.transformArguments(),
|
||||||
['PUBSUB', 'CHANNELS']
|
['PUBSUB', 'CHANNELS']
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
it('with pattern', () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments('patter*'),
|
|
||||||
['PUBSUB', 'CHANNELS', 'patter*']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.pubSubChannels', async client => {
|
it('with pattern', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.pubSubChannels(),
|
PUBSUB_CHANNELS.transformArguments('patter*'),
|
||||||
[]
|
['PUBSUB', 'CHANNELS', 'patter*']
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
testUtils.testWithClient('client.pubSubChannels', async client => {
|
||||||
|
assert.deepEqual(
|
||||||
|
await client.pubSubChannels(),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,19 +1,19 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import testUtils, { GLOBAL } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './PUBSUB_NUMPAT';
|
import PUBSUB_NUMPAT from './PUBSUB_NUMPAT';
|
||||||
|
|
||||||
describe('PUBSUB NUMPAT', () => {
|
describe('PUBSUB NUMPAT', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments(),
|
PUBSUB_NUMPAT.transformArguments(),
|
||||||
['PUBSUB', 'NUMPAT']
|
['PUBSUB', 'NUMPAT']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.pubSubNumPat', async client => {
|
testUtils.testWithClient('client.pubSubNumPat', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.pubSubNumPat(),
|
await client.pubSubNumPat(),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,35 +1,35 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import testUtils, { GLOBAL } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './PUBSUB_NUMSUB';
|
import PUBSUB_NUMSUB from './PUBSUB_NUMSUB';
|
||||||
|
|
||||||
describe('PUBSUB NUMSUB', () => {
|
describe('PUBSUB NUMSUB', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments(),
|
PUBSUB_NUMSUB.transformArguments(),
|
||||||
['PUBSUB', 'NUMSUB']
|
['PUBSUB', 'NUMSUB']
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
it('string', () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments('channel'),
|
|
||||||
['PUBSUB', 'NUMSUB', 'channel']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('array', () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments(['1', '2']),
|
|
||||||
['PUBSUB', 'NUMSUB', '1', '2']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.pubSubNumSub', async client => {
|
it('string', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.pubSubNumSub(),
|
PUBSUB_NUMSUB.transformArguments('channel'),
|
||||||
Object.create(null)
|
['PUBSUB', 'NUMSUB', 'channel']
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
});
|
||||||
|
|
||||||
|
it('array', () => {
|
||||||
|
assert.deepEqual(
|
||||||
|
PUBSUB_NUMSUB.transformArguments(['1', '2']),
|
||||||
|
['PUBSUB', 'NUMSUB', '1', '2']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
testUtils.testWithClient('client.pubSubNumSub', async client => {
|
||||||
|
assert.deepEqual(
|
||||||
|
await client.pubSubNumSub(),
|
||||||
|
Object.create(null)
|
||||||
|
);
|
||||||
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,30 +1,30 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import testUtils, { GLOBAL } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './PUBSUB_SHARDCHANNELS';
|
import PUBSUB_SHARDCHANNELS from './PUBSUB_SHARDCHANNELS';
|
||||||
|
|
||||||
describe('PUBSUB SHARDCHANNELS', () => {
|
describe('PUBSUB SHARDCHANNELS', () => {
|
||||||
testUtils.isVersionGreaterThanHook([7]);
|
testUtils.isVersionGreaterThanHook([7]);
|
||||||
|
|
||||||
describe('transformArguments', () => {
|
|
||||||
it('without pattern', () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments(),
|
|
||||||
['PUBSUB', 'SHARDCHANNELS']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('with pattern', () => {
|
describe('transformArguments', () => {
|
||||||
assert.deepEqual(
|
it('without pattern', () => {
|
||||||
transformArguments('patter*'),
|
assert.deepEqual(
|
||||||
['PUBSUB', 'SHARDCHANNELS', 'patter*']
|
PUBSUB_SHARDCHANNELS.transformArguments(),
|
||||||
);
|
['PUBSUB', 'SHARDCHANNELS']
|
||||||
});
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.pubSubShardChannels', async client => {
|
it('with pattern', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.pubSubShardChannels(),
|
PUBSUB_SHARDCHANNELS.transformArguments('patter*'),
|
||||||
[]
|
['PUBSUB', 'SHARDCHANNELS', 'patter*']
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
testUtils.testWithClient('client.pubSubShardChannels', async client => {
|
||||||
|
assert.deepEqual(
|
||||||
|
await client.pubSubShardChannels(),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -4,7 +4,7 @@ export default {
|
|||||||
FIRST_KEY_INDEX: undefined,
|
FIRST_KEY_INDEX: undefined,
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(pattern?: RedisArgument) {
|
transformArguments(pattern?: RedisArgument) {
|
||||||
const args: Array<RedisArgument> = ['PUBSUB', 'bb'];
|
const args: Array<RedisArgument> = ['PUBSUB', 'SHARDCHANNELS'];
|
||||||
|
|
||||||
if (pattern) {
|
if (pattern) {
|
||||||
args.push(pattern);
|
args.push(pattern);
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { transformArguments } from './READONLY';
|
import READONLY from './READONLY';
|
||||||
|
|
||||||
describe('READONLY', () => {
|
describe('READONLY', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments(),
|
READONLY.transformArguments(),
|
||||||
['READONLY']
|
['READONLY']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { transformArguments } from './READWRITE';
|
import READWRITE from './READWRITE';
|
||||||
|
|
||||||
describe('READWRITE', () => {
|
describe('READWRITE', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments(),
|
READWRITE.transformArguments(),
|
||||||
['READWRITE']
|
['READWRITE']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { transformArguments } from './REPLICAOF';
|
import REPLICAOF from './REPLICAOF';
|
||||||
|
|
||||||
describe('REPLICAOF', () => {
|
describe('REPLICAOF', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('host', 1),
|
REPLICAOF.transformArguments('host', 1),
|
||||||
['REPLICAOF', 'host', '1']
|
['REPLICAOF', 'host', '1']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { transformArguments } from './RESTORE-ASKING';
|
import RESTORE_ASKING from './RESTORE-ASKING';
|
||||||
|
|
||||||
describe('RESTORE-ASKING', () => {
|
describe('RESTORE-ASKING', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments(),
|
RESTORE_ASKING.transformArguments(),
|
||||||
['RESTORE-ASKING']
|
['RESTORE-ASKING']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { transformArguments } from './SAVE';
|
import SAVE from './SAVE';
|
||||||
|
|
||||||
describe('SAVE', () => {
|
describe('SAVE', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments(),
|
SAVE.transformArguments(),
|
||||||
['SAVE']
|
['SAVE']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -103,8 +103,8 @@ import INCRBYFLOAT from './INCRBYFLOAT';
|
|||||||
import INFO from './INFO';
|
import INFO from './INFO';
|
||||||
import KEYS from './KEYS';
|
import KEYS from './KEYS';
|
||||||
import LASTSAVE from './LASTSAVE';
|
import LASTSAVE from './LASTSAVE';
|
||||||
// import LCS_IDX_WITHMATCHLEN from './LCS_IDX_WITHMATCHLEN';
|
import LCS_IDX_WITHMATCHLEN from './LCS_IDX_WITHMATCHLEN';
|
||||||
// import LCS_IDX from './LCS_IDX';
|
import LCS_IDX from './LCS_IDX';
|
||||||
import LCS_LEN from './LCS_LEN';
|
import LCS_LEN from './LCS_LEN';
|
||||||
import LCS from './LCS';
|
import LCS from './LCS';
|
||||||
import LINDEX from './LINDEX';
|
import LINDEX from './LINDEX';
|
||||||
@@ -112,6 +112,7 @@ import LINSERT from './LINSERT';
|
|||||||
import LLEN from './LLEN';
|
import LLEN from './LLEN';
|
||||||
import LMOVE from './LMOVE';
|
import LMOVE from './LMOVE';
|
||||||
import LMPOP from './LMPOP';
|
import LMPOP from './LMPOP';
|
||||||
|
import LOLWUT from './LOLWUT';
|
||||||
import LPOP_COUNT from './LPOP_COUNT';
|
import LPOP_COUNT from './LPOP_COUNT';
|
||||||
import LPOP from './LPOP';
|
import LPOP from './LPOP';
|
||||||
import LPOS_COUNT from './LPOS_COUNT';
|
import LPOS_COUNT from './LPOS_COUNT';
|
||||||
@@ -122,7 +123,15 @@ import LRANGE from './LRANGE';
|
|||||||
import LREM from './LREM';
|
import LREM from './LREM';
|
||||||
import LSET from './LSET';
|
import LSET from './LSET';
|
||||||
import LTRIM from './LTRIM';
|
import LTRIM from './LTRIM';
|
||||||
|
import MEMORY_DOCTOR from './MEMORY_DOCTOR';
|
||||||
|
import MEMORY_MALLOC_STATS from './MEMORY_MALLOC-STATS';
|
||||||
|
import MEMORY_PURGE from './MEMORY_PURGE';
|
||||||
|
// import MEMORY_STATS from './MEMORY_STATS';
|
||||||
|
import MEMORY_USAGE from './MEMORY_USAGE';
|
||||||
import MGET from './MGET';
|
import MGET from './MGET';
|
||||||
|
import MODULE_LIST from './MODULE_LIST';
|
||||||
|
import MODULE_LOAD from './MODULE_LOAD';
|
||||||
|
import MODULE_UNLOAD from './MODULE_UNLOAD';
|
||||||
import MOVE from './MOVE';
|
import MOVE from './MOVE';
|
||||||
import MSET from './MSET';
|
import MSET from './MSET';
|
||||||
import MSETNX from './MSETNX';
|
import MSETNX from './MSETNX';
|
||||||
@@ -140,6 +149,11 @@ import PFMERGE from './PFMERGE';
|
|||||||
import PING from './PING';
|
import PING from './PING';
|
||||||
import PSETEX from './PSETEX';
|
import PSETEX from './PSETEX';
|
||||||
import PTTL from './PTTL';
|
import PTTL from './PTTL';
|
||||||
|
import PUBLISH from './PUBLISH';
|
||||||
|
import PUBSUB_CHANNELS from './PUBSUB_CHANNELS';
|
||||||
|
import PUBSUB_NUMPAT from './PUBSUB_NUMPAT';
|
||||||
|
import PUBSUB_NUMSUB from './PUBSUB_NUMSUB';
|
||||||
|
import PUBSUB_SHARDCHANNELS from './PUBSUB_SHARDCHANNELS';
|
||||||
import RANDOMKEY from './RANDOMKEY';
|
import RANDOMKEY from './RANDOMKEY';
|
||||||
import READONLY from './READONLY';
|
import READONLY from './READONLY';
|
||||||
import RENAME from './RENAME';
|
import RENAME from './RENAME';
|
||||||
@@ -443,8 +457,10 @@ export default {
|
|||||||
keys: KEYS,
|
keys: KEYS,
|
||||||
LASTSAVE,
|
LASTSAVE,
|
||||||
lastSave: LASTSAVE,
|
lastSave: LASTSAVE,
|
||||||
// LCS_IDX_WITHMATCHLEN,
|
LCS_IDX_WITHMATCHLEN,
|
||||||
// LCS_IDX,
|
lcsIdxWithMatchLen: LCS_IDX_WITHMATCHLEN,
|
||||||
|
LCS_IDX,
|
||||||
|
lcsIdx: LCS_IDX,
|
||||||
LCS_LEN,
|
LCS_LEN,
|
||||||
lcsLen: LCS_LEN,
|
lcsLen: LCS_LEN,
|
||||||
LCS,
|
LCS,
|
||||||
@@ -459,6 +475,7 @@ export default {
|
|||||||
lMove: LMOVE,
|
lMove: LMOVE,
|
||||||
LMPOP,
|
LMPOP,
|
||||||
lmPop: LMPOP,
|
lmPop: LMPOP,
|
||||||
|
LOLWUT,
|
||||||
LPOP_COUNT,
|
LPOP_COUNT,
|
||||||
lPopCount: LPOP_COUNT,
|
lPopCount: LPOP_COUNT,
|
||||||
LPOP,
|
LPOP,
|
||||||
@@ -479,8 +496,24 @@ export default {
|
|||||||
lSet: LSET,
|
lSet: LSET,
|
||||||
LTRIM,
|
LTRIM,
|
||||||
lTrim: LTRIM,
|
lTrim: LTRIM,
|
||||||
|
MEMORY_DOCTOR,
|
||||||
|
memoryDoctor: MEMORY_DOCTOR,
|
||||||
|
'MEMORY_MALLOC-STATS': MEMORY_MALLOC_STATS,
|
||||||
|
memoryMallocStats: MEMORY_MALLOC_STATS,
|
||||||
|
MEMORY_PURGE,
|
||||||
|
memoryPurge: MEMORY_PURGE,
|
||||||
|
// MEMORY_STATS,
|
||||||
|
// memoryStats: MEMORY_STATS,
|
||||||
|
MEMORY_USAGE,
|
||||||
|
memoryUsage: MEMORY_USAGE,
|
||||||
MGET,
|
MGET,
|
||||||
mGet: MGET,
|
mGet: MGET,
|
||||||
|
MODULE_LIST,
|
||||||
|
moduleList: MODULE_LIST,
|
||||||
|
MODULE_LOAD,
|
||||||
|
moduleLoad: MODULE_LOAD,
|
||||||
|
MODULE_UNLOAD,
|
||||||
|
moduleUnload: MODULE_UNLOAD,
|
||||||
MOVE,
|
MOVE,
|
||||||
move: MOVE,
|
move: MOVE,
|
||||||
MSET,
|
MSET,
|
||||||
@@ -518,6 +551,16 @@ export default {
|
|||||||
pSetEx: PSETEX,
|
pSetEx: PSETEX,
|
||||||
PTTL,
|
PTTL,
|
||||||
pTTL: PTTL,
|
pTTL: PTTL,
|
||||||
|
PUBLISH,
|
||||||
|
publish: PUBLISH,
|
||||||
|
PUBSUB_CHANNELS,
|
||||||
|
pubSubChannels: PUBSUB_CHANNELS,
|
||||||
|
PUBSUB_NUMPAT,
|
||||||
|
pubSubNumPat: PUBSUB_NUMPAT,
|
||||||
|
PUBSUB_NUMSUB,
|
||||||
|
pubSubNumSub: PUBSUB_NUMSUB,
|
||||||
|
PUBSUB_SHARDCHANNELS,
|
||||||
|
pubSubShardChannels: PUBSUB_SHARDCHANNELS,
|
||||||
RANDOMKEY,
|
RANDOMKEY,
|
||||||
randomKey: RANDOMKEY,
|
randomKey: RANDOMKEY,
|
||||||
READONLY,
|
READONLY,
|
||||||
|
Reference in New Issue
Block a user