You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
WIP
This commit is contained in:
@@ -385,10 +385,10 @@ export class Decoder {
|
||||
}
|
||||
|
||||
// Precalculated multipliers for decimal points to improve performance
|
||||
// "A Number only keeps about 17 decimal places of precision"
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number
|
||||
// "... about 15 to 17 decimal places ..."
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number#:~:text=about%2015%20to%2017%20decimal%20places
|
||||
static _DOUBLE_DECIMAL_MULTIPLIERS = [
|
||||
0.1, 0.01, 0.001, 0.0001, 0.00001, 0.000001,
|
||||
1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6,
|
||||
1e-7, 1e-8, 1e-9, 1e-10, 1e-11, 1e-12,
|
||||
1e-13, 1e-14, 1e-15, 1e-16, 1e-17
|
||||
];
|
||||
|
@@ -19,7 +19,7 @@ describe('BITOP', () => {
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testAll('client.bitOp', async client => {
|
||||
testUtils.testAll('bitOp', async client => {
|
||||
assert.equal(
|
||||
await client.bitOp('AND', '{tag}destKey', '{tag}key'),
|
||||
0
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { SimpleStringReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(value: boolean) {
|
||||
return [
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { BlobStringReply, NullReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments() {
|
||||
return [
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { NumberReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments() {
|
||||
return ['CLIENT', 'GETREDIR']
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { NumberReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments() {
|
||||
return ['CLIENT', 'ID'];
|
||||
|
@@ -56,6 +56,7 @@ export interface ClientInfoReply {
|
||||
const CLIENT_INFO_REGEX = /([^\s=]+)=([^\s]*)/g;
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments() {
|
||||
return ['CLIENT', 'INFO']
|
||||
|
@@ -42,6 +42,7 @@ export type ClientKillSkipMe = CLIENT_KILL_FILTERS['SKIP_ME'] | (ClientKillFilte
|
||||
export type ClientKillFilter = ClientKillAddress | ClientKillLocalAddress | ClientKillId | ClientKillType | ClientKillUser | ClientKillSkipMe;
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(filters: ClientKillFilter | Array<ClientKillFilter>) {
|
||||
const args = ['CLIENT', 'KILL'];
|
||||
|
@@ -15,6 +15,7 @@ export interface ListFilterId {
|
||||
export type ListFilter = ListFilterType | ListFilterId;
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(filter?: ListFilter) {
|
||||
let args: Array<RedisArgument> = ['CLIENT', 'LIST'];
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { SimpleStringReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(value: boolean) {
|
||||
return [
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { SimpleStringReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(timeout: number, mode?: 'WRITE' | 'ALL') {
|
||||
const args = [
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { RedisArgument, SimpleStringReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(name: RedisArgument) {
|
||||
return ['CLIENT', 'SETNAME', name];
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { SimpleStringReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments() {
|
||||
return ['CLIENT', 'UNPAUSE'];
|
||||
|
@@ -2,6 +2,7 @@ import { SimpleStringReply, Command } from '../RESP/types';
|
||||
import { pushVariadicNumberArguments } from './generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(slots: number | Array<number>) {
|
||||
return pushVariadicNumberArguments(
|
||||
|
@@ -2,6 +2,7 @@ import { SimpleStringReply, Command } from '../RESP/types';
|
||||
import { pushSlotRangesArguments, SlotRange } from './generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(ranges: SlotRange | Array<SlotRange>) {
|
||||
return pushSlotRangesArguments(
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { SimpleStringReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments() {
|
||||
return ['CLUSTER', 'BUMPEPOCH'];
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { RedisArgument, NumberReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(nodeId: RedisArgument) {
|
||||
return ['CLUSTER', 'COUNT-FAILURE-REPORTS', nodeId];
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { NumberReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(slot: number) {
|
||||
return ['CLUSTER', 'COUNT-FAILURE-REPORTS', slot.toString()];
|
||||
|
@@ -2,6 +2,7 @@ import { SimpleStringReply, Command } from '../RESP/types';
|
||||
import { pushVariadicNumberArguments } from './generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(slots: number | Array<number>) {
|
||||
return pushVariadicNumberArguments(
|
||||
|
@@ -2,6 +2,7 @@ import { SimpleStringReply, Command } from '../RESP/types';
|
||||
import { pushSlotRangesArguments, SlotRange } from './generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(ranges: SlotRange | Array<SlotRange>) {
|
||||
return pushSlotRangesArguments(
|
||||
|
@@ -8,6 +8,7 @@ export const FAILOVER_MODES = {
|
||||
export type FailoverModes = typeof FAILOVER_MODES[keyof typeof FAILOVER_MODES];
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(mode?: FailoverModes) {
|
||||
const args = ['CLUSTER', 'FAILOVER'];
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { SimpleStringReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments() {
|
||||
return ['CLUSTER', 'FLUSHSLOTS'];
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { RedisArgument, SimpleStringReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(nodeId: RedisArgument) {
|
||||
return ['CLUSTER', 'FORGET', nodeId];
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { ArrayReply, BlobStringReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(slot: number, count: number) {
|
||||
return ['CLUSTER', 'GETKEYSINSLOT', slot.toString(), count.toString()];
|
||||
|
@@ -16,6 +16,7 @@ type ClusterSlotsRawReply = ArrayReply<[
|
||||
export type ClusterSlotsNode = ReturnType<typeof transformNode>;
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments() {
|
||||
return ['CLUSTER', 'SLOTS'];
|
||||
|
@@ -2,6 +2,7 @@ import { RedisArgument, Command } from '../RESP/types';
|
||||
import { transformTuplesReply } from './generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(parameter: RedisArgument) {
|
||||
return ['CONFIG', 'GET', parameter];
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { NumberReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments() {
|
||||
return ['DBSIZE'];
|
||||
|
@@ -3,6 +3,7 @@ import { RedisVariadicArgument, pushVariadicArguments } from './generic-transfor
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(keys: RedisVariadicArgument) {
|
||||
return pushVariadicArguments(['DEL'], keys);
|
||||
},
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { RedisArgument, BlobStringReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(message: RedisArgument) {
|
||||
return ['ECHO', message];
|
||||
|
@@ -1,33 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import RedisClient from '../client';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './GET';
|
||||
import GET from './GET';
|
||||
|
||||
describe('GET', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key'),
|
||||
['GET', 'key']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
GET.transformArguments('key'),
|
||||
['GET', 'key']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.get', async client => {
|
||||
const a = await client.get(
|
||||
'key'
|
||||
);
|
||||
|
||||
|
||||
|
||||
assert.equal(
|
||||
await client.get('key'),
|
||||
null
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
|
||||
testUtils.testWithCluster('cluster.get', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.get('key'),
|
||||
null
|
||||
);
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
testUtils.testAll('get', async client => {
|
||||
assert.equal(
|
||||
await client.get('key'),
|
||||
null
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,26 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './GETBIT';
|
||||
import GETBIT from './GETBIT';
|
||||
|
||||
describe('GETBIT', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 0),
|
||||
['GETBIT', 'key', '0']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
GETBIT.transformArguments('key', 0),
|
||||
['GETBIT', 'key', '0']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.getBit', async client => {
|
||||
assert.equal(
|
||||
await client.getBit('key', 0),
|
||||
0
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
|
||||
testUtils.testWithCluster('cluster.getBit', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.getBit('key', 0),
|
||||
0
|
||||
);
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
testUtils.testAll('getBit', async client => {
|
||||
assert.equal(
|
||||
await client.getBit('key', 0),
|
||||
0
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,28 +1,24 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './GETDEL';
|
||||
import GETDEL from './GETDEL';
|
||||
|
||||
describe('GETDEL', () => {
|
||||
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key'),
|
||||
['GETDEL', 'key']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
GETDEL.transformArguments('key'),
|
||||
['GETDEL', 'key']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.getDel', async client => {
|
||||
assert.equal(
|
||||
await client.getDel('key'),
|
||||
null
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
|
||||
testUtils.testWithCluster('cluster.getDel', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.getDel('key'),
|
||||
null
|
||||
);
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
testUtils.testAll('getDel', async client => {
|
||||
assert.equal(
|
||||
await client.getDel('key'),
|
||||
null
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,96 +1,122 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './GETEX';
|
||||
import GETEX from './GETEX';
|
||||
|
||||
describe('GETEX', () => {
|
||||
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||
|
||||
describe('transformArguments', () => {
|
||||
it('EX', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', {
|
||||
EX: 1
|
||||
}),
|
||||
['GETEX', 'key', 'EX', '1']
|
||||
);
|
||||
});
|
||||
|
||||
it('PX', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', {
|
||||
PX: 1
|
||||
}),
|
||||
['GETEX', 'key', 'PX', '1']
|
||||
);
|
||||
});
|
||||
|
||||
describe('EXAT', () => {
|
||||
it('number', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', {
|
||||
EXAT: 1
|
||||
}),
|
||||
['GETEX', 'key', 'EXAT', '1']
|
||||
);
|
||||
});
|
||||
|
||||
it('date', () => {
|
||||
const d = new Date();
|
||||
assert.deepEqual(
|
||||
transformArguments('key', {
|
||||
EXAT: d
|
||||
}),
|
||||
['GETEX', 'key', 'EXAT', Math.floor(d.getTime() / 1000).toString()]
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('PXAT', () => {
|
||||
it('number', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', {
|
||||
PXAT: 1
|
||||
}),
|
||||
['GETEX', 'key', 'PXAT', '1']
|
||||
);
|
||||
});
|
||||
|
||||
it('date', () => {
|
||||
const d = new Date();
|
||||
assert.deepEqual(
|
||||
transformArguments('key', {
|
||||
PXAT: d
|
||||
}),
|
||||
['GETEX', 'key', 'PXAT', d.getTime().toString()]
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('PERSIST', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', {
|
||||
PERSIST: true
|
||||
}),
|
||||
['GETEX', 'key', 'PERSIST']
|
||||
);
|
||||
});
|
||||
describe('transformArguments', () => {
|
||||
it('EX | PX', () => {
|
||||
assert.deepEqual(
|
||||
GETEX.transformArguments('key', {
|
||||
type: 'EX',
|
||||
value: 1
|
||||
}),
|
||||
['GETEX', 'key', 'EX', '1']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.getEx', async client => {
|
||||
assert.equal(
|
||||
await client.getEx('key', {
|
||||
PERSIST: true
|
||||
}),
|
||||
null
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
it('EX (backwards compatibility)', () => {
|
||||
assert.deepEqual(
|
||||
GETEX.transformArguments('key', {
|
||||
EX: 1
|
||||
}),
|
||||
['GETEX', 'key', 'EX', '1']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithCluster('cluster.getEx', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.getEx('key', {
|
||||
PERSIST: true
|
||||
}),
|
||||
null
|
||||
it('PX (backwards compatibility)', () => {
|
||||
assert.deepEqual(
|
||||
GETEX.transformArguments('key', {
|
||||
PX: 1
|
||||
}),
|
||||
['GETEX', 'key', 'PX', '1']
|
||||
);
|
||||
});
|
||||
|
||||
describe('EXAT | PXAT', () => {
|
||||
it('number', () => {
|
||||
assert.deepEqual(
|
||||
GETEX.transformArguments('key', {
|
||||
type: 'EXAT',
|
||||
value: 1
|
||||
}),
|
||||
['GETEX', 'key', 'EXAT', '1']
|
||||
);
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
});
|
||||
|
||||
it('date', () => {
|
||||
const d = new Date();
|
||||
assert.deepEqual(
|
||||
GETEX.transformArguments('key', {
|
||||
EXAT: d
|
||||
}),
|
||||
['GETEX', 'key', 'EXAT', Math.floor(d.getTime() / 1000).toString()]
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('EXAT (backwards compatibility)', () => {
|
||||
it('number', () => {
|
||||
assert.deepEqual(
|
||||
GETEX.transformArguments('key', {
|
||||
EXAT: 1
|
||||
}),
|
||||
['GETEX', 'key', 'EXAT', '1']
|
||||
);
|
||||
});
|
||||
|
||||
it('date', () => {
|
||||
const d = new Date();
|
||||
assert.deepEqual(
|
||||
GETEX.transformArguments('key', {
|
||||
EXAT: d
|
||||
}),
|
||||
['GETEX', 'key', 'EXAT', Math.floor(d.getTime() / 1000).toString()]
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('PXAT (backwards compatibility)', () => {
|
||||
it('number', () => {
|
||||
assert.deepEqual(
|
||||
GETEX.transformArguments('key', {
|
||||
PXAT: 1
|
||||
}),
|
||||
['GETEX', 'key', 'PXAT', '1']
|
||||
);
|
||||
});
|
||||
|
||||
it('date', () => {
|
||||
const d = new Date();
|
||||
assert.deepEqual(
|
||||
GETEX.transformArguments('key', {
|
||||
PXAT: d
|
||||
}),
|
||||
['GETEX', 'key', 'PXAT', d.getTime().toString()]
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('PERSIST (backwards compatibility)', () => {
|
||||
assert.deepEqual(
|
||||
GETEX.transformArguments('key', {
|
||||
PERSIST: true
|
||||
}),
|
||||
['GETEX', 'key', 'PERSIST']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testAll('getEx', async client => {
|
||||
assert.equal(
|
||||
await client.getEx('key', {
|
||||
type: 'PERSIST'
|
||||
}),
|
||||
null
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,34 +1,75 @@
|
||||
import { RedisArgument, BlobStringReply, NullReply, Command } from '../RESP/types';
|
||||
import { transformEXAT, transformPXAT } from './generic-transformers';
|
||||
|
||||
export type GetExModes = {
|
||||
export type GetExOptions = {
|
||||
type: 'EX' | 'PX';
|
||||
value: number;
|
||||
} | {
|
||||
type: 'EXAT' | 'PXAT';
|
||||
value: number | Date;
|
||||
} | {
|
||||
type: 'PERSIST';
|
||||
} | {
|
||||
/**
|
||||
* @deprecated Use `{ type: 'EX', value: number }` instead.
|
||||
*/
|
||||
EX: number;
|
||||
} | {
|
||||
/**
|
||||
* @deprecated Use `{ type: 'PX', value: number }` instead.
|
||||
*/
|
||||
PX: number;
|
||||
} | {
|
||||
/**
|
||||
* @deprecated Use `{ type: 'EXAT', value: number | Date }` instead.
|
||||
*/
|
||||
EXAT: number | Date;
|
||||
} | {
|
||||
/**
|
||||
* @deprecated Use `{ type: 'PXAT', value: number | Date }` instead.
|
||||
*/
|
||||
PXAT: number | Date;
|
||||
} | {
|
||||
/**
|
||||
* @deprecated Use `{ type: 'PERSIST' }` instead.
|
||||
*/
|
||||
PERSIST: true;
|
||||
};
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument, mode: GetExModes) {
|
||||
transformArguments(key: RedisArgument, options: GetExOptions) {
|
||||
const args = ['GETEX', key];
|
||||
|
||||
if ('EX' in mode) {
|
||||
args.push('EX', mode.EX.toString());
|
||||
} else if ('PX' in mode) {
|
||||
args.push('PX', mode.PX.toString());
|
||||
} else if ('EXAT' in mode) {
|
||||
args.push('EXAT', transformEXAT(mode.EXAT));
|
||||
} else if ('PXAT' in mode) {
|
||||
args.push('PXAT', transformPXAT(mode.PXAT));
|
||||
} else { // PERSIST
|
||||
args.push('PERSIST');
|
||||
if ('type' in options) {
|
||||
switch (options.type) {
|
||||
case 'EX':
|
||||
case 'PX':
|
||||
args.push(options.type, options.value.toString());
|
||||
break;
|
||||
|
||||
case 'EXAT':
|
||||
case 'PXAT':
|
||||
args.push(options.type, transformEXAT(options.value));
|
||||
break;
|
||||
|
||||
case 'PERSIST':
|
||||
args.push('PERSIST');
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if ('EX' in options) {
|
||||
args.push('EX', options.EX.toString());
|
||||
} else if ('PX' in options) {
|
||||
args.push('PX', options.PX.toString());
|
||||
} else if ('EXAT' in options) {
|
||||
args.push('EXAT', transformEXAT(options.EXAT));
|
||||
} else if ('PXAT' in options) {
|
||||
args.push('PXAT', transformPXAT(options.PXAT));
|
||||
} else { // PERSIST
|
||||
args.push('PERSIST');
|
||||
}
|
||||
}
|
||||
|
||||
return args;
|
||||
|
@@ -1,26 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './GETRANGE';
|
||||
import GETRANGE from './GETRANGE';
|
||||
|
||||
describe('GETRANGE', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 0, -1),
|
||||
['GETRANGE', 'key', '0', '-1']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
GETRANGE.transformArguments('key', 0, -1),
|
||||
['GETRANGE', 'key', '0', '-1']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.getRange', async client => {
|
||||
assert.equal(
|
||||
await client.getRange('key', 0, -1),
|
||||
''
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
|
||||
testUtils.testWithCluster('cluster.lTrim', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.getRange('key', 0, -1),
|
||||
''
|
||||
);
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
testUtils.testAll('getRange', async client => {
|
||||
assert.equal(
|
||||
await client.getRange('key', 0, -1),
|
||||
''
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,26 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './GETSET';
|
||||
import GETSET from './GETSET';
|
||||
|
||||
describe('GETSET', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'value'),
|
||||
['GETSET', 'key', 'value']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
GETSET.transformArguments('key', 'value'),
|
||||
['GETSET', 'key', 'value']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.getSet', async client => {
|
||||
assert.equal(
|
||||
await client.getSet('key', 'value'),
|
||||
null
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
|
||||
testUtils.testWithCluster('cluster.getSet', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.getSet('key', 'value'),
|
||||
null
|
||||
);
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
testUtils.testAll('getSet', async client => {
|
||||
assert.equal(
|
||||
await client.getSet('key', 'value'),
|
||||
null
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,28 +1,31 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './HDEL';
|
||||
import HDEL from './HDEL';
|
||||
|
||||
describe('HDEL', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('string', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'field'),
|
||||
['HDEL', 'key', 'field']
|
||||
);
|
||||
});
|
||||
|
||||
it('array', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', ['1', '2']),
|
||||
['HDEL', 'key', '1', '2']
|
||||
);
|
||||
});
|
||||
describe('transformArguments', () => {
|
||||
it('string', () => {
|
||||
assert.deepEqual(
|
||||
HDEL.transformArguments('key', 'field'),
|
||||
['HDEL', 'key', 'field']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.hDel', async client => {
|
||||
assert.equal(
|
||||
await client.hDel('key', 'field'),
|
||||
0
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
it('array', () => {
|
||||
assert.deepEqual(
|
||||
HDEL.transformArguments('key', ['1', '2']),
|
||||
['HDEL', 'key', '1', '2']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testAll('hDel', async client => {
|
||||
assert.equal(
|
||||
await client.hDel('key', 'field'),
|
||||
0
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,19 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './HEXISTS';
|
||||
import HEXISTS from './HEXISTS';
|
||||
|
||||
describe('HEXISTS', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'field'),
|
||||
['HEXISTS', 'key', 'field']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
HEXISTS.transformArguments('key', 'field'),
|
||||
['HEXISTS', 'key', 'field']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.hExists', async client => {
|
||||
assert.equal(
|
||||
await client.hExists('key', 'field'),
|
||||
false
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
testUtils.testAll('hExists', async client => {
|
||||
assert.equal(
|
||||
await client.hExists('key', 'field'),
|
||||
0
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,19 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './HGET';
|
||||
import HGET from './HGET';
|
||||
|
||||
describe('HGET', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'field'),
|
||||
['HGET', 'key', 'field']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
HGET.transformArguments('key', 'field'),
|
||||
['HGET', 'key', 'field']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.hGet', async client => {
|
||||
assert.equal(
|
||||
await client.hGet('key', 'field'),
|
||||
null
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
testUtils.testAll('hGet', async client => {
|
||||
assert.equal(
|
||||
await client.hGet('key', 'field'),
|
||||
null
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,19 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './HINCRBY';
|
||||
import HINCRBY from './HINCRBY';
|
||||
|
||||
describe('HINCRBY', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'field', 1),
|
||||
['HINCRBY', 'key', 'field', '1']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
HINCRBY.transformArguments('key', 'field', 1),
|
||||
['HINCRBY', 'key', 'field', '1']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.hIncrBy', async client => {
|
||||
assert.equal(
|
||||
await client.hIncrBy('key', 'field', 1),
|
||||
1
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
testUtils.testAll('hIncrBy', async client => {
|
||||
assert.equal(
|
||||
await client.hIncrBy('key', 'field', 1),
|
||||
1
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,19 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './HINCRBYFLOAT';
|
||||
import HINCRBYFLOAT from './HINCRBYFLOAT';
|
||||
|
||||
describe('HINCRBYFLOAT', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'field', 1.5),
|
||||
['HINCRBYFLOAT', 'key', 'field', '1.5']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
HINCRBYFLOAT.transformArguments('key', 'field', 1.5),
|
||||
['HINCRBYFLOAT', 'key', 'field', '1.5']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.hIncrByFloat', async client => {
|
||||
assert.equal(
|
||||
await client.hIncrByFloat('key', 'field', 1.5),
|
||||
'1.5'
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
testUtils.testAll('hIncrByFloat', async client => {
|
||||
assert.equal(
|
||||
await client.hIncrByFloat('key', 'field', 1.5),
|
||||
'1.5'
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,19 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './HKEYS';
|
||||
import HKEYS from './HKEYS';
|
||||
|
||||
describe('HKEYS', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key'),
|
||||
['HKEYS', 'key']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
HKEYS.transformArguments('key'),
|
||||
['HKEYS', 'key']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.hKeys', async client => {
|
||||
assert.deepEqual(
|
||||
await client.hKeys('key'),
|
||||
[]
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
testUtils.testAll('hKeys', async client => {
|
||||
assert.deepEqual(
|
||||
await client.hKeys('key'),
|
||||
[]
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,19 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './HLEN';
|
||||
import HLEN from './HLEN';
|
||||
|
||||
describe('HLEN', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key'),
|
||||
['HLEN', 'key']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
HLEN.transformArguments('key'),
|
||||
['HLEN', 'key']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.hLen', async client => {
|
||||
assert.equal(
|
||||
await client.hLen('key'),
|
||||
0
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
testUtils.testAll('hLen', async client => {
|
||||
assert.equal(
|
||||
await client.hLen('key'),
|
||||
0
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,28 +1,31 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './HMGET';
|
||||
import HMGET from './HMGET';
|
||||
|
||||
describe('HMGET', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('string', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'field'),
|
||||
['HMGET', 'key', 'field']
|
||||
);
|
||||
});
|
||||
|
||||
it('array', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', ['field1', 'field2']),
|
||||
['HMGET', 'key', 'field1', 'field2']
|
||||
);
|
||||
});
|
||||
describe('transformArguments', () => {
|
||||
it('string', () => {
|
||||
assert.deepEqual(
|
||||
HMGET.transformArguments('key', 'field'),
|
||||
['HMGET', 'key', 'field']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.hmGet', async client => {
|
||||
assert.deepEqual(
|
||||
await client.hmGet('key', 'field'),
|
||||
[null]
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
it('array', () => {
|
||||
assert.deepEqual(
|
||||
HMGET.transformArguments('key', ['field1', 'field2']),
|
||||
['HMGET', 'key', 'field1', 'field2']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testAll('hmGet', async client => {
|
||||
assert.deepEqual(
|
||||
await client.hmGet('key', 'field'),
|
||||
[null]
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -8,7 +8,7 @@ export default {
|
||||
key: RedisArgument,
|
||||
fields: RedisVariadicArgument
|
||||
) {
|
||||
return pushVariadicArguments(['HMGET'], fields);
|
||||
return pushVariadicArguments(['HMGET', key], fields);
|
||||
},
|
||||
transformReply: undefined as unknown as () => ArrayReply<BlobStringReply | NullReply>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,21 +1,24 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './HRANDFIELD';
|
||||
import HRANDFIELD from './HRANDFIELD';
|
||||
|
||||
describe('HRANDFIELD', () => {
|
||||
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key'),
|
||||
['HRANDFIELD', 'key']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
HRANDFIELD.transformArguments('key'),
|
||||
['HRANDFIELD', 'key']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.hRandField', async client => {
|
||||
assert.equal(
|
||||
await client.hRandField('key'),
|
||||
null
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
testUtils.testAll('hRandField', async client => {
|
||||
assert.equal(
|
||||
await client.hRandField('key'),
|
||||
null
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,21 +1,24 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './HRANDFIELD_COUNT';
|
||||
import HRANDFIELD_COUNT from './HRANDFIELD_COUNT';
|
||||
|
||||
describe('HRANDFIELD COUNT', () => {
|
||||
testUtils.isVersionGreaterThanHook([6, 2, 5]);
|
||||
testUtils.isVersionGreaterThanHook([6, 2, 5]);
|
||||
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 1),
|
||||
['HRANDFIELD', 'key', '1']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
HRANDFIELD_COUNT.transformArguments('key', 1),
|
||||
['HRANDFIELD', 'key', '1']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.hRandFieldCount', async client => {
|
||||
assert.deepEqual(
|
||||
await client.hRandFieldCount('key', 1),
|
||||
[]
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
testUtils.testAll('hRandFieldCount', async client => {
|
||||
assert.deepEqual(
|
||||
await client.hRandFieldCount('key', 1),
|
||||
[]
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,77 +1,56 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments, transformReply } from './HSCAN';
|
||||
import HSCAN from './HSCAN';
|
||||
|
||||
describe('HSCAN', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('cusror only', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 0),
|
||||
['HSCAN', 'key', '0']
|
||||
);
|
||||
});
|
||||
|
||||
it('with MATCH', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 0, {
|
||||
MATCH: 'pattern'
|
||||
}),
|
||||
['HSCAN', 'key', '0', 'MATCH', 'pattern']
|
||||
);
|
||||
});
|
||||
|
||||
it('with COUNT', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 0, {
|
||||
COUNT: 1
|
||||
}),
|
||||
['HSCAN', 'key', '0', 'COUNT', '1']
|
||||
);
|
||||
});
|
||||
|
||||
it('with MATCH & COUNT', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 0, {
|
||||
MATCH: 'pattern',
|
||||
COUNT: 1
|
||||
}),
|
||||
['HSCAN', 'key', '0', 'MATCH', 'pattern', 'COUNT', '1']
|
||||
);
|
||||
});
|
||||
describe('transformArguments', () => {
|
||||
it('cusror only', () => {
|
||||
assert.deepEqual(
|
||||
HSCAN.transformArguments('key', 0),
|
||||
['HSCAN', 'key', '0']
|
||||
);
|
||||
});
|
||||
|
||||
describe('transformReply', () => {
|
||||
it('without tuples', () => {
|
||||
assert.deepEqual(
|
||||
transformReply(['0', []]),
|
||||
{
|
||||
cursor: 0,
|
||||
tuples: []
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('with tuples', () => {
|
||||
assert.deepEqual(
|
||||
transformReply(['0', ['field', 'value']]),
|
||||
{
|
||||
cursor: 0,
|
||||
tuples: [{
|
||||
field: 'field',
|
||||
value: 'value'
|
||||
}]
|
||||
}
|
||||
);
|
||||
});
|
||||
it('with MATCH', () => {
|
||||
assert.deepEqual(
|
||||
HSCAN.transformArguments('key', 0, {
|
||||
MATCH: 'pattern'
|
||||
}),
|
||||
['HSCAN', 'key', '0', 'MATCH', 'pattern']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.hScan', async client => {
|
||||
assert.deepEqual(
|
||||
await client.hScan('key', 0),
|
||||
{
|
||||
cursor: 0,
|
||||
tuples: []
|
||||
}
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
it('with COUNT', () => {
|
||||
assert.deepEqual(
|
||||
HSCAN.transformArguments('key', 0, {
|
||||
COUNT: 1
|
||||
}),
|
||||
['HSCAN', 'key', '0', 'COUNT', '1']
|
||||
);
|
||||
});
|
||||
|
||||
it('with MATCH & COUNT', () => {
|
||||
assert.deepEqual(
|
||||
HSCAN.transformArguments('key', 0, {
|
||||
MATCH: 'pattern',
|
||||
COUNT: 1
|
||||
}),
|
||||
['HSCAN', 'key', '0', 'MATCH', 'pattern', 'COUNT', '1']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.hScan', async client => {
|
||||
await client.hSet('key', 'field', 'value');
|
||||
assert.deepEqual(
|
||||
await client.hScan('key', 0),
|
||||
{
|
||||
cursor: 0,
|
||||
entries: [{
|
||||
field: 'field',
|
||||
value: 'value'
|
||||
}]
|
||||
}
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -1,74 +1,70 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { transformArguments } from './HSET';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import HSET from './HSET';
|
||||
|
||||
describe('HSET', () => {
|
||||
describe('transformArguments', () => {
|
||||
describe('field, value', () => {
|
||||
it('string', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'field', 'value'),
|
||||
['HSET', 'key', 'field', 'value']
|
||||
);
|
||||
});
|
||||
describe('transformArguments', () => {
|
||||
describe('field, value', () => {
|
||||
it('string', () => {
|
||||
assert.deepEqual(
|
||||
HSET.transformArguments('key', 'field', 'value'),
|
||||
['HSET', 'key', 'field', 'value']
|
||||
);
|
||||
});
|
||||
|
||||
it('number', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 1, 2),
|
||||
['HSET', 'key', '1', '2']
|
||||
);
|
||||
});
|
||||
it('number', () => {
|
||||
assert.deepEqual(
|
||||
HSET.transformArguments('key', 1, 2),
|
||||
['HSET', 'key', '1', '2']
|
||||
);
|
||||
});
|
||||
|
||||
it('Buffer', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments(Buffer.from('key'), Buffer.from('field'), Buffer.from('value')),
|
||||
['HSET', Buffer.from('key'), Buffer.from('field'), Buffer.from('value')]
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('Map', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', new Map([['field', 'value']])),
|
||||
['HSET', 'key', 'field', 'value']
|
||||
);
|
||||
});
|
||||
|
||||
it('Array', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', [['field', 'value']]),
|
||||
['HSET', 'key', 'field', 'value']
|
||||
);
|
||||
});
|
||||
|
||||
describe('Object', () => {
|
||||
it('string', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', { field: 'value' }),
|
||||
['HSET', 'key', 'field', 'value']
|
||||
);
|
||||
});
|
||||
|
||||
it('Buffer', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', { field: Buffer.from('value') }),
|
||||
['HSET', 'key', 'field', Buffer.from('value')]
|
||||
);
|
||||
});
|
||||
});
|
||||
it('Buffer', () => {
|
||||
assert.deepEqual(
|
||||
HSET.transformArguments(Buffer.from('key'), Buffer.from('field'), Buffer.from('value')),
|
||||
['HSET', Buffer.from('key'), Buffer.from('field'), Buffer.from('value')]
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.hSet', async client => {
|
||||
assert.equal(
|
||||
await client.hSet('key', 'field', 'value'),
|
||||
1
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
it('Map', () => {
|
||||
assert.deepEqual(
|
||||
HSET.transformArguments('key', new Map([['field', 'value']])),
|
||||
['HSET', 'key', 'field', 'value']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithCluster('cluster.hSet', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.hSet('key', { field: 'value' }),
|
||||
1
|
||||
it('Array', () => {
|
||||
assert.deepEqual(
|
||||
HSET.transformArguments('key', [['field', 'value']]),
|
||||
['HSET', 'key', 'field', 'value']
|
||||
);
|
||||
});
|
||||
|
||||
describe('Object', () => {
|
||||
it('string', () => {
|
||||
assert.deepEqual(
|
||||
HSET.transformArguments('key', { field: 'value' }),
|
||||
['HSET', 'key', 'field', 'value']
|
||||
);
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
});
|
||||
|
||||
it('Buffer', () => {
|
||||
assert.deepEqual(
|
||||
HSET.transformArguments('key', { field: Buffer.from('value') }),
|
||||
['HSET', 'key', 'field', Buffer.from('value')]
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testAll('hSet', async client => {
|
||||
assert.equal(
|
||||
await client.hSet('key', 'field', 'value'),
|
||||
1
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,19 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './HSETNX';
|
||||
import HSETNX from './HSETNX';
|
||||
|
||||
describe('HSETNX', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'field', 'value'),
|
||||
['HSETNX', 'key', 'field', 'value']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
HSETNX.transformArguments('key', 'field', 'value'),
|
||||
['HSETNX', 'key', 'field', 'value']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.hSetNX', async client => {
|
||||
assert.equal(
|
||||
await client.hSetNX('key', 'field', 'value'),
|
||||
true
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
testUtils.testAll('hSetNX', async client => {
|
||||
assert.equal(
|
||||
await client.hSetNX('key', 'field', 'value'),
|
||||
1
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,19 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './HSTRLEN';
|
||||
import HSTRLEN from './HSTRLEN';
|
||||
|
||||
describe('HSTRLEN', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'field'),
|
||||
['HSTRLEN', 'key', 'field']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
HSTRLEN.transformArguments('key', 'field'),
|
||||
['HSTRLEN', 'key', 'field']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.hStrLen', async client => {
|
||||
assert.equal(
|
||||
await client.hStrLen('key', 'field'),
|
||||
0
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
testUtils.testAll('hStrLen', async client => {
|
||||
assert.equal(
|
||||
await client.hStrLen('key', 'field'),
|
||||
0
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -4,7 +4,7 @@ export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument, field: RedisArgument) {
|
||||
return ['HSETLEN', key, field];
|
||||
return ['HSTRLEN', key, field];
|
||||
},
|
||||
transformReply: undefined as unknown as () => ArrayReply<BlobStringReply>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,19 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './HVALS';
|
||||
import HVALS from './HVALS';
|
||||
|
||||
describe('HVALS', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key'),
|
||||
['HVALS', 'key']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
HVALS.transformArguments('key'),
|
||||
['HVALS', 'key']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.hVals', async client => {
|
||||
assert.deepEqual(
|
||||
await client.hVals('key'),
|
||||
[]
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
testUtils.testAll('hVals', async client => {
|
||||
assert.deepEqual(
|
||||
await client.hVals('key'),
|
||||
[]
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,19 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './INCR';
|
||||
import INCR from './INCR';
|
||||
|
||||
describe('INCR', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key'),
|
||||
['INCR', 'key']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
INCR.transformArguments('key'),
|
||||
['INCR', 'key']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.incr', async client => {
|
||||
assert.equal(
|
||||
await client.incr('key'),
|
||||
1
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
testUtils.testAll('incr', async client => {
|
||||
assert.equal(
|
||||
await client.incr('key'),
|
||||
1
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,19 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './INCRBY';
|
||||
import INCRBY from './INCRBY';
|
||||
|
||||
describe('INCR', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 1),
|
||||
['INCRBY', 'key', '1']
|
||||
);
|
||||
});
|
||||
describe('INCRBY', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
INCRBY.transformArguments('key', 1),
|
||||
['INCRBY', 'key', '1']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.incrBy', async client => {
|
||||
assert.equal(
|
||||
await client.incrBy('key', 1),
|
||||
1
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
testUtils.testAll('incrBy', async client => {
|
||||
assert.equal(
|
||||
await client.incrBy('key', 1),
|
||||
1
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,19 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './INCRBYFLOAT';
|
||||
import INCRBYFLOAT from './INCRBYFLOAT';
|
||||
|
||||
describe('INCRBYFLOAT', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 1.5),
|
||||
['INCRBYFLOAT', 'key', '1.5']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
INCRBYFLOAT.transformArguments('key', 1.5),
|
||||
['INCRBYFLOAT', 'key', '1.5']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.incrByFloat', async client => {
|
||||
assert.equal(
|
||||
await client.incrByFloat('key', 1.5),
|
||||
'1.5'
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
testUtils.testAll('incrByFloat', async client => {
|
||||
assert.equal(
|
||||
await client.incrByFloat('key', 1.5),
|
||||
'1.5'
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { RedisArgument, VerbatimStringReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(section?: RedisArgument) {
|
||||
const args: Array<RedisArgument> = ['INFO'];
|
||||
|
@@ -2,10 +2,10 @@ import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
|
||||
describe('KEYS', () => {
|
||||
testUtils.testWithClient('client.keys', async client => {
|
||||
assert.deepEqual(
|
||||
await client.keys('pattern'),
|
||||
[]
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
testUtils.testWithClient('client.keys', async client => {
|
||||
assert.deepEqual(
|
||||
await client.keys('pattern'),
|
||||
[]
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(pattern: RedisArgument) {
|
||||
return ['KEYS', pattern];
|
||||
|
@@ -1,28 +1,24 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './LCS';
|
||||
import LCS from './LCS';
|
||||
|
||||
describe('LCS', () => {
|
||||
testUtils.isVersionGreaterThanHook([7]);
|
||||
testUtils.isVersionGreaterThanHook([7]);
|
||||
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('1', '2'),
|
||||
['LCS', '1', '2']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
LCS.transformArguments('1', '2'),
|
||||
['LCS', '1', '2']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.lcs', async client => {
|
||||
assert.equal(
|
||||
await client.lcs('1', '2'),
|
||||
''
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
|
||||
testUtils.testWithCluster('cluster.lcs', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.lcs('{tag}1', '{tag}2'),
|
||||
''
|
||||
);
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
testUtils.testAll('lcs', async client => {
|
||||
assert.equal(
|
||||
await client.lcs('1', '2'),
|
||||
''
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,28 +1,24 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './LCS_LEN';
|
||||
import LCS_LEN from './LCS_LEN';
|
||||
|
||||
describe('LCS_LEN', () => {
|
||||
testUtils.isVersionGreaterThanHook([7]);
|
||||
testUtils.isVersionGreaterThanHook([7]);
|
||||
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('1', '2'),
|
||||
['LCS', '1', '2', 'LEN']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
LCS_LEN.transformArguments('1', '2'),
|
||||
['LCS', '1', '2', 'LEN']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.lcsLen', async client => {
|
||||
assert.equal(
|
||||
await client.lcsLen('1', '2'),
|
||||
0
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
|
||||
testUtils.testWithCluster('cluster.lcsLen', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.lcsLen('{tag}1', '{tag}2'),
|
||||
0
|
||||
);
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
testUtils.testAll('lcsLen', async client => {
|
||||
assert.equal(
|
||||
await client.lcsLen('1', '2'),
|
||||
0
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,36 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './LINDEX';
|
||||
import LINDEX from './LINDEX';
|
||||
|
||||
describe('LINDEX', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 0),
|
||||
['LINDEX', 'key', '0']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
LINDEX.transformArguments('key', 0),
|
||||
['LINDEX', 'key', '0']
|
||||
);
|
||||
});
|
||||
|
||||
describe('client.lIndex', () => {
|
||||
testUtils.testWithClient('null', async client => {
|
||||
assert.equal(
|
||||
await client.lIndex('key', 0),
|
||||
null
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
|
||||
testUtils.testWithClient('with value', async client => {
|
||||
const [, lIndexReply] = await Promise.all([
|
||||
client.lPush('key', 'element'),
|
||||
client.lIndex('key', 0)
|
||||
]);
|
||||
|
||||
assert.equal(lIndexReply, 'element');
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
||||
testUtils.testWithCluster('cluster.lIndex', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.lIndex('key', 0),
|
||||
null
|
||||
);
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
testUtils.testAll('lIndex', async client => {
|
||||
assert.equal(
|
||||
await client.lIndex('key', 0),
|
||||
null
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
@@ -1,26 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './LINSERT';
|
||||
import LINSERT from './LINSERT';
|
||||
|
||||
describe('LINSERT', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', 'BEFORE', 'pivot', 'element'),
|
||||
['LINSERT', 'key', 'BEFORE', 'pivot', 'element']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
LINSERT.transformArguments('key', 'BEFORE', 'pivot', 'element'),
|
||||
['LINSERT', 'key', 'BEFORE', 'pivot', 'element']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.lInsert', async client => {
|
||||
assert.equal(
|
||||
await client.lInsert('key', 'BEFORE', 'pivot', 'element'),
|
||||
0
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
|
||||
testUtils.testWithCluster('cluster.lInsert', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.lInsert('key', 'BEFORE', 'pivot', 'element'),
|
||||
0
|
||||
);
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
testUtils.testAll('lInsert', async client => {
|
||||
assert.equal(
|
||||
await client.lInsert('key', 'BEFORE', 'pivot', 'element'),
|
||||
0
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -14,7 +14,7 @@ describe('LMOVE', () => {
|
||||
|
||||
testUtils.testAll('lMove', async client => {
|
||||
assert.equal(
|
||||
await client.lMove('source', 'destination', 'LEFT', 'RIGHT'),
|
||||
await client.lMove('{tag}source', '{tag}destination', 'LEFT', 'RIGHT'),
|
||||
null
|
||||
);
|
||||
}, {
|
||||
|
@@ -23,7 +23,7 @@ describe('LMPOP', () => {
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testAll('client.lmPop', async client => {
|
||||
testUtils.testAll('lmPop', async client => {
|
||||
assert.deepEqual(
|
||||
await client.lmPop('key', 'RIGHT'),
|
||||
null
|
||||
|
@@ -11,6 +11,7 @@ describe('LSET', () => {
|
||||
});
|
||||
|
||||
testUtils.testAll('lSet', async client => {
|
||||
await client.lPush('key', 'element');
|
||||
assert.equal(
|
||||
await client.lSet('key', 0, 'element'),
|
||||
'OK'
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { RedisArgument, SimpleStringReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(message?: RedisArgument) {
|
||||
const args: Array<RedisArgument> = ['PING'];
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { NumberReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments() {
|
||||
return ['RANDOMKEY'];
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { RedisArgument, SimpleStringReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument, newKey: RedisArgument) {
|
||||
return ['RENAME', key, newKey];
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { RedisArgument, SimpleStringReply, Command, NumberReply } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument, newKey: RedisArgument) {
|
||||
return ['RENAMENX', key, newKey];
|
||||
|
@@ -28,6 +28,7 @@ export interface ScanOptions extends ScanCommonOptions {
|
||||
}
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(cursor: number, options?: ScanOptions) {
|
||||
const args = pushScanArguments(['SCAN'], cursor, options);
|
||||
|
@@ -89,7 +89,7 @@ describe('SORT_RO', () => {
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testAll('client.sortRo', async client => {
|
||||
testUtils.testAll('sortRo', async client => {
|
||||
assert.deepEqual(
|
||||
await client.sortRo('key'),
|
||||
[]
|
||||
|
@@ -1,28 +1,22 @@
|
||||
// import { strict as assert } from 'assert';
|
||||
// import testUtils, { GLOBAL } from '../test-utils';
|
||||
// import { transformArguments } from './SPOP';
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import SPOP from './SPOP';
|
||||
|
||||
// describe('SPOP', () => {
|
||||
// describe('transformArguments', () => {
|
||||
// it('simple', () => {
|
||||
// assert.deepEqual(
|
||||
// transformArguments('key'),
|
||||
// ['SPOP', 'key']
|
||||
// );
|
||||
// });
|
||||
describe('SPOP', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
SPOP.transformArguments('key'),
|
||||
['SPOP', 'key']
|
||||
);
|
||||
});
|
||||
|
||||
// it('with count', () => {
|
||||
// assert.deepEqual(
|
||||
// transformArguments('key', 2),
|
||||
// ['SPOP', 'key', '2']
|
||||
// );
|
||||
// });
|
||||
// });
|
||||
|
||||
// testUtils.testWithClient('client.sPop', async client => {
|
||||
// assert.equal(
|
||||
// await client.sPop('key'),
|
||||
// null
|
||||
// );
|
||||
// }, GLOBAL.SERVERS.OPEN);
|
||||
// });
|
||||
testUtils.testAll('sPop', async client => {
|
||||
assert.equal(
|
||||
await client.sPop('key'),
|
||||
null
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,18 +1,10 @@
|
||||
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { RedisArgument, BlobStringReply, NullReply, Command } from '../RESP/types';
|
||||
|
||||
// export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
// export function transformArguments(
|
||||
// key: RedisCommandArgument,
|
||||
// count?: number
|
||||
// ): RedisCommandArguments {
|
||||
// const args = ['SPOP', key];
|
||||
|
||||
// if (typeof count === 'number') {
|
||||
// args.push(count.toString());
|
||||
// }
|
||||
|
||||
// return args;
|
||||
// }
|
||||
|
||||
// export declare function transformReply(): Array<RedisCommandArgument>;
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(key: RedisArgument) {
|
||||
return ['SPOP', key];
|
||||
},
|
||||
transformReply: undefined as unknown as () => BlobStringReply | NullReply
|
||||
} as const satisfies Command;
|
||||
|
22
packages/client/lib/commands/SPOP_COUNT.spec.ts
Normal file
22
packages/client/lib/commands/SPOP_COUNT.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import SPOP_COUNT from './SPOP_COUNT';
|
||||
|
||||
describe('SPOP_COUNT', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
SPOP_COUNT.transformArguments('key', 1),
|
||||
['SPOP', 'key', '1']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testAll('sPopCount', async client => {
|
||||
assert.deepEqual(
|
||||
await client.sPopCount('key', 1),
|
||||
[]
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
10
packages/client/lib/commands/SPOP_COUNT.ts
Normal file
10
packages/client/lib/commands/SPOP_COUNT.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { RedisArgument, BlobStringReply, NullReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(key: RedisArgument, count: number) {
|
||||
return ['SPOP', key, count.toString()];
|
||||
},
|
||||
transformReply: undefined as unknown as () => BlobStringReply | NullReply
|
||||
} as const satisfies Command;
|
@@ -19,7 +19,7 @@ describe('SREM', () => {
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testAll('client.sRem', async client => {
|
||||
testUtils.testAll('sRem', async client => {
|
||||
assert.equal(
|
||||
await client.sRem('key', 'member'),
|
||||
0
|
||||
|
@@ -42,7 +42,9 @@ import CLUSTER_MYID from './CLUSTER_MYID';
|
||||
import CLUSTER_REPLICATE from './CLUSTER_REPLICATE';
|
||||
import DECR from './DECR';
|
||||
import DECRBY from './DECRBY';
|
||||
import GEODIST from './GEODIST';
|
||||
import GET from './GET';
|
||||
import GETBIT from './GETBIT';
|
||||
import GETDEL from './GETDEL';
|
||||
import GETEX from './GETEX';
|
||||
import GETRANGE from './GETRANGE';
|
||||
@@ -69,6 +71,7 @@ import INCR from './INCR';
|
||||
import INCRBY from './INCRBY';
|
||||
import INCRBYFLOAT from './INCRBYFLOAT';
|
||||
import INFO from './INFO';
|
||||
import KEYS from './KEYS';
|
||||
// import LCS_IDX_WITHMATCHLEN from './LCS_IDX_WITHMATCHLEN';
|
||||
// import LCS_IDX from './LCS_IDX';
|
||||
import LCS_LEN from './LCS_LEN';
|
||||
@@ -128,6 +131,8 @@ import SMISMEMBER from './SMISMEMBER';
|
||||
import SORT_RO from './SORT_RO';
|
||||
import SORT_STORE from './SORT_STORE';
|
||||
import SORT from './SORT';
|
||||
import SPOP_COUNT from './SPOP_COUNT';
|
||||
import SPOP from './SPOP';
|
||||
import SPUBLISH from './SPUBLISH';
|
||||
import SRANDMEMBER_COUNT from './SRANDMEMBER_COUNT';
|
||||
import SRANDMEMBER from './SRANDMEMBER';
|
||||
@@ -257,6 +262,8 @@ export default {
|
||||
decrBy: DECRBY,
|
||||
GET,
|
||||
get: GET,
|
||||
GETBIT,
|
||||
getBit: GETBIT,
|
||||
GETDEL,
|
||||
getDel: GETDEL,
|
||||
GETEX,
|
||||
@@ -284,7 +291,7 @@ export default {
|
||||
HLEN,
|
||||
hLen: HLEN,
|
||||
HMGET,
|
||||
hMGet: HMGET,
|
||||
hmGet: HMGET,
|
||||
HRANDFIELD_COUNT_WITHVALUES,
|
||||
hRandFieldCountWithValues: HRANDFIELD_COUNT_WITHVALUES,
|
||||
HRANDFIELD_COUNT,
|
||||
@@ -296,7 +303,7 @@ export default {
|
||||
HSET,
|
||||
hSet: HSET,
|
||||
HSETNX,
|
||||
hSetNx: HSETNX,
|
||||
hSetNX: HSETNX,
|
||||
HSTRLEN,
|
||||
hStrLen: HSTRLEN,
|
||||
HVALS,
|
||||
@@ -309,6 +316,8 @@ export default {
|
||||
incrByFloat: INCRBYFLOAT,
|
||||
INFO,
|
||||
info: INFO,
|
||||
KEYS,
|
||||
keys: KEYS,
|
||||
// LCS_IDX_WITHMATCHLEN,
|
||||
// LCS_IDX,
|
||||
LCS_LEN,
|
||||
@@ -428,6 +437,10 @@ export default {
|
||||
sortStore: SORT_STORE,
|
||||
SORT,
|
||||
sort: SORT,
|
||||
SPOP_COUNT,
|
||||
sPopCount: SPOP_COUNT,
|
||||
SPOP,
|
||||
sPop: SPOP,
|
||||
SPUBLISH,
|
||||
sPublish: SPUBLISH,
|
||||
SRANDMEMBER_COUNT,
|
||||
|
Reference in New Issue
Block a user