You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
some more commands
This commit is contained in:
@@ -1,26 +1,22 @@
|
|||||||
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 './LLEN';
|
import LLEN from './LLEN';
|
||||||
|
|
||||||
describe('LLEN', () => {
|
describe('LLEN', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key'),
|
LLEN.transformArguments('key'),
|
||||||
['LLEN', 'key']
|
['LLEN', 'key']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.lLen', async client => {
|
testUtils.testAll('lLen', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.lLen('key'),
|
await client.lLen('key'),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
testUtils.testWithCluster('cluster.lLen', async cluster => {
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
assert.equal(
|
});
|
||||||
await cluster.lLen('key'),
|
|
||||||
0
|
|
||||||
);
|
|
||||||
}, GLOBAL.CLUSTERS.OPEN);
|
|
||||||
});
|
});
|
||||||
|
@@ -1,28 +1,24 @@
|
|||||||
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 './LMOVE';
|
import LMOVE from './LMOVE';
|
||||||
|
|
||||||
describe('LMOVE', () => {
|
describe('LMOVE', () => {
|
||||||
testUtils.isVersionGreaterThanHook([6, 2]);
|
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('source', 'destination', 'LEFT', 'RIGHT'),
|
LMOVE.transformArguments('source', 'destination', 'LEFT', 'RIGHT'),
|
||||||
['LMOVE', 'source', 'destination', 'LEFT', 'RIGHT']
|
['LMOVE', 'source', 'destination', 'LEFT', 'RIGHT']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.lMove', async client => {
|
testUtils.testAll('lMove', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.lMove('source', 'destination', 'LEFT', 'RIGHT'),
|
await client.lMove('source', 'destination', 'LEFT', 'RIGHT'),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
testUtils.testWithCluster('cluster.lMove', async cluster => {
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
assert.equal(
|
});
|
||||||
await cluster.lMove('{tag}source', '{tag}destination', 'LEFT', 'RIGHT'),
|
|
||||||
null
|
|
||||||
);
|
|
||||||
}, GLOBAL.CLUSTERS.OPEN);
|
|
||||||
});
|
});
|
||||||
|
@@ -3,6 +3,7 @@ import { ListSide } from './generic-transformers';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
FIRST_KEY_INDEX: 1,
|
||||||
|
IS_READ_ONLY: false,
|
||||||
transformArguments(
|
transformArguments(
|
||||||
source: RedisArgument,
|
source: RedisArgument,
|
||||||
destination: RedisArgument,
|
destination: RedisArgument,
|
||||||
|
@@ -1,32 +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 './LMPOP';
|
import LMPOP from './LMPOP';
|
||||||
|
|
||||||
describe('LMPOP', () => {
|
describe('LMPOP', () => {
|
||||||
testUtils.isVersionGreaterThanHook([7]);
|
testUtils.isVersionGreaterThanHook([7]);
|
||||||
|
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', 'LEFT'),
|
LMPOP.transformArguments('key', 'LEFT'),
|
||||||
['LMPOP', '1', 'key', 'LEFT']
|
['LMPOP', '1', 'key', 'LEFT']
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
it('with COUNT', () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments('key', 'LEFT', {
|
|
||||||
COUNT: 2
|
|
||||||
}),
|
|
||||||
['LMPOP', '1', 'key', 'LEFT', 'COUNT', '2']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.lmPop', async client => {
|
it('with COUNT', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.lmPop('key', 'RIGHT'),
|
LMPOP.transformArguments('key', 'LEFT', {
|
||||||
null
|
COUNT: 2
|
||||||
);
|
}),
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
['LMPOP', '1', 'key', 'LEFT', 'COUNT', '2']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
testUtils.testAll('client.lmPop', async client => {
|
||||||
|
assert.deepEqual(
|
||||||
|
await client.lmPop('key', 'RIGHT'),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.SERVERS.OPEN
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -3,6 +3,7 @@ import { transformLMPopArguments, LMPopOptions, ListSide, RedisVariadicArgument
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 2,
|
FIRST_KEY_INDEX: 2,
|
||||||
|
IS_READ_ONLY: false,
|
||||||
transformArguments(
|
transformArguments(
|
||||||
keys: RedisVariadicArgument,
|
keys: RedisVariadicArgument,
|
||||||
side: ListSide,
|
side: ListSide,
|
||||||
|
@@ -9,11 +9,11 @@ export default {
|
|||||||
element: RedisArgument
|
element: RedisArgument
|
||||||
) {
|
) {
|
||||||
return [
|
return [
|
||||||
'LREM',
|
'LSET',
|
||||||
key,
|
key,
|
||||||
index.toString(),
|
index.toString(),
|
||||||
element
|
element
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => SimpleStringReply
|
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -8,11 +8,11 @@ export default {
|
|||||||
stop: number
|
stop: number
|
||||||
) {
|
) {
|
||||||
return [
|
return [
|
||||||
'LREM',
|
'LTRIM',
|
||||||
key,
|
key,
|
||||||
start.toString(),
|
start.toString(),
|
||||||
stop.toString()
|
stop.toString()
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => SimpleStringReply
|
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||||
} as const satisfies Command;
|
} 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 './MOVE';
|
import MOVE from './MOVE';
|
||||||
|
|
||||||
describe('MOVE', () => {
|
describe('MOVE', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', 1),
|
MOVE.transformArguments('key', 1),
|
||||||
['MOVE', 'key', '1']
|
['MOVE', 'key', '1']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.move', async client => {
|
testUtils.testWithClient('client.move', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.move('key', 1),
|
await client.move('key', 1),
|
||||||
false
|
1
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,42 +1,38 @@
|
|||||||
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 './MSET';
|
import MSET from './MSET';
|
||||||
|
|
||||||
describe('MSET', () => {
|
describe('MSET', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it("['key1', 'value1', 'key2', 'value2']", () => {
|
it("['key1', 'value1', 'key2', 'value2']", () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments(['key1', 'value1', 'key2', 'value2']),
|
MSET.transformArguments(['key1', 'value1', 'key2', 'value2']),
|
||||||
['MSET', 'key1', 'value1', 'key2', 'value2']
|
['MSET', 'key1', 'value1', 'key2', 'value2']
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
it("[['key1', 'value1'], ['key2', 'value2']]", () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments([['key1', 'value1'], ['key2', 'value2']]),
|
|
||||||
['MSET', 'key1', 'value1', 'key2', 'value2']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("{key1: 'value1'. key2: 'value2'}", () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments({ key1: 'value1', key2: 'value2' }),
|
|
||||||
['MSET', 'key1', 'value1', 'key2', 'value2']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.mSet', async client => {
|
it("[['key1', 'value1'], ['key2', 'value2']]", () => {
|
||||||
assert.equal(
|
assert.deepEqual(
|
||||||
await client.mSet(['key1', 'value1', 'key2', 'value2']),
|
MSET.transformArguments([['key1', 'value1'], ['key2', 'value2']]),
|
||||||
'OK'
|
['MSET', 'key1', 'value1', 'key2', 'value2']
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
});
|
||||||
|
|
||||||
testUtils.testWithCluster('cluster.mSet', async cluster => {
|
it("{key1: 'value1'. key2: 'value2'}", () => {
|
||||||
assert.equal(
|
assert.deepEqual(
|
||||||
await cluster.mSet(['{key}1', 'value1', '{key}2', 'value2']),
|
MSET.transformArguments({ key1: 'value1', key2: 'value2' }),
|
||||||
'OK'
|
['MSET', 'key1', 'value1', 'key2', 'value2']
|
||||||
);
|
);
|
||||||
}, GLOBAL.CLUSTERS.OPEN);
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
testUtils.testAll('mSet', async client => {
|
||||||
|
assert.equal(
|
||||||
|
await client.mSet(['key1', 'value1', 'key2', 'value2']),
|
||||||
|
'OK'
|
||||||
|
);
|
||||||
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,42 +1,38 @@
|
|||||||
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 './MSETNX';
|
import MSETNX from './MSETNX';
|
||||||
|
|
||||||
describe('MSETNX', () => {
|
describe('MSETNX', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it("['key1', 'value1', 'key2', 'value2']", () => {
|
it("['key1', 'value1', 'key2', 'value2']", () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments(['key1', 'value1', 'key2', 'value2']),
|
MSETNX.transformArguments(['key1', 'value1', 'key2', 'value2']),
|
||||||
['MSETNX', 'key1', 'value1', 'key2', 'value2']
|
['MSETNX', 'key1', 'value1', 'key2', 'value2']
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
it("[['key1', 'value1'], ['key2', 'value2']]", () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments([['key1', 'value1'], ['key2', 'value2']]),
|
|
||||||
['MSETNX', 'key1', 'value1', 'key2', 'value2']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("{key1: 'value1'. key2: 'value2'}", () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments({ key1: 'value1', key2: 'value2' }),
|
|
||||||
['MSETNX', 'key1', 'value1', 'key2', 'value2']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.mSetNX', async client => {
|
it("[['key1', 'value1'], ['key2', 'value2']]", () => {
|
||||||
assert.equal(
|
assert.deepEqual(
|
||||||
await client.mSetNX(['key1', 'value1', 'key2', 'value2']),
|
MSETNX.transformArguments([['key1', 'value1'], ['key2', 'value2']]),
|
||||||
true
|
['MSETNX', 'key1', 'value1', 'key2', 'value2']
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
});
|
||||||
|
|
||||||
testUtils.testWithCluster('cluster.mSetNX', async cluster => {
|
it("{key1: 'value1'. key2: 'value2'}", () => {
|
||||||
assert.equal(
|
assert.deepEqual(
|
||||||
await cluster.mSetNX(['{key}1', 'value1', '{key}2', 'value2']),
|
MSETNX.transformArguments({ key1: 'value1', key2: 'value2' }),
|
||||||
true
|
['MSETNX', 'key1', 'value1', 'key2', 'value2']
|
||||||
);
|
);
|
||||||
}, GLOBAL.CLUSTERS.OPEN);
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
testUtils.testAll('mSetNX', async client => {
|
||||||
|
assert.equal(
|
||||||
|
await client.mSetNX(['{key}1', 'value1', '{key}2', 'value2']),
|
||||||
|
1
|
||||||
|
);
|
||||||
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,19 +1,22 @@
|
|||||||
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 './PERSIST';
|
import PERSIST from './PERSIST';
|
||||||
|
|
||||||
describe('PERSIST', () => {
|
describe('PERSIST', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key'),
|
PERSIST.transformArguments('key'),
|
||||||
['PERSIST', 'key']
|
['PERSIST', 'key']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.persist', async client => {
|
testUtils.testAll('persist', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.persist('key'),
|
await client.persist('key'),
|
||||||
false
|
0
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,28 +1,31 @@
|
|||||||
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 './PEXPIRE';
|
import PEXPIRE from './PEXPIRE';
|
||||||
|
|
||||||
describe('PEXPIRE', () => {
|
describe('PEXPIRE', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', 1),
|
PEXPIRE.transformArguments('key', 1),
|
||||||
['PEXPIRE', 'key', '1']
|
['PEXPIRE', 'key', '1']
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
it('with set option', () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments('key', 1, 'GT'),
|
|
||||||
['PEXPIRE', 'key', '1', 'GT']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.pExpire', async client => {
|
it('with set option', () => {
|
||||||
assert.equal(
|
assert.deepEqual(
|
||||||
await client.pExpire('key', 1),
|
PEXPIRE.transformArguments('key', 1, 'GT'),
|
||||||
false
|
['PEXPIRE', 'key', '1', 'GT']
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
testUtils.testAll('pExpire', async client => {
|
||||||
|
assert.equal(
|
||||||
|
await client.pExpire('key', 1),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,36 +1,39 @@
|
|||||||
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 './PEXPIREAT';
|
import PEXPIREAT from './PEXPIREAT';
|
||||||
|
|
||||||
describe('PEXPIREAT', () => {
|
describe('PEXPIREAT', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('number', () => {
|
it('number', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', 1),
|
PEXPIREAT.transformArguments('key', 1),
|
||||||
['PEXPIREAT', 'key', '1']
|
['PEXPIREAT', 'key', '1']
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
it('date', () => {
|
|
||||||
const d = new Date();
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments('key', d),
|
|
||||||
['PEXPIREAT', 'key', d.getTime().toString()]
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('with set option', () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments('key', 1, 'XX'),
|
|
||||||
['PEXPIREAT', 'key', '1', 'XX']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.pExpireAt', async client => {
|
it('date', () => {
|
||||||
assert.equal(
|
const d = new Date();
|
||||||
await client.pExpireAt('key', 1),
|
assert.deepEqual(
|
||||||
false
|
PEXPIREAT.transformArguments('key', d),
|
||||||
);
|
['PEXPIREAT', 'key', d.getTime().toString()]
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('with set option', () => {
|
||||||
|
assert.deepEqual(
|
||||||
|
PEXPIREAT.transformArguments('key', 1, 'XX'),
|
||||||
|
['PEXPIREAT', 'key', '1', 'XX']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
testUtils.testAll('pExpireAt', async client => {
|
||||||
|
assert.equal(
|
||||||
|
await client.pExpireAt('key', 1),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,21 +1,24 @@
|
|||||||
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 './PEXPIRETIME';
|
import PEXPIRETIME from './PEXPIRETIME';
|
||||||
|
|
||||||
describe('PEXPIRETIME', () => {
|
describe('PEXPIRETIME', () => {
|
||||||
testUtils.isVersionGreaterThanHook([7]);
|
testUtils.isVersionGreaterThanHook([7]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key'),
|
PEXPIRETIME.transformArguments('key'),
|
||||||
['PEXPIRETIME', 'key']
|
['PEXPIRETIME', 'key']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.pExpireTime', async client => {
|
testUtils.testAll('pExpireTime', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.pExpireTime('key'),
|
await client.pExpireTime('key'),
|
||||||
-2
|
-2
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -4,7 +4,7 @@ export default {
|
|||||||
FIRST_KEY_INDEX: 1,
|
FIRST_KEY_INDEX: 1,
|
||||||
IS_READ_ONLY: true,
|
IS_READ_ONLY: true,
|
||||||
transformArguments(key: RedisArgument) {
|
transformArguments(key: RedisArgument) {
|
||||||
return ['PEXPIREAT', key];
|
return ['PEXPIRETIME', key];
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => NumberReply
|
transformReply: undefined as unknown as () => NumberReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,28 +1,31 @@
|
|||||||
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 './PFADD';
|
import PFADD from './PFADD';
|
||||||
|
|
||||||
describe('PFADD', () => {
|
describe('PFADD', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('string', () => {
|
it('string', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', 'element'),
|
PFADD.transformArguments('key', 'element'),
|
||||||
['PFADD', 'key', 'element']
|
['PFADD', 'key', 'element']
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
it('array', () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments('key', ['1', '2']),
|
|
||||||
['PFADD', 'key', '1', '2']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.pfAdd', async client => {
|
it('array', () => {
|
||||||
assert.equal(
|
assert.deepEqual(
|
||||||
await client.pfAdd('key', '1'),
|
PFADD.transformArguments('key', ['1', '2']),
|
||||||
true
|
['PFADD', 'key', '1', '2']
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
testUtils.testAll('pfAdd', async client => {
|
||||||
|
assert.equal(
|
||||||
|
await client.pfAdd('key', '1'),
|
||||||
|
1
|
||||||
|
);
|
||||||
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '../RESP/types';
|
import { RedisArgument, NumberReply, Command } from '../RESP/types';
|
||||||
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -10,5 +10,5 @@ export default {
|
|||||||
|
|
||||||
return pushVariadicArguments(args, element);
|
return pushVariadicArguments(args, element);
|
||||||
},
|
},
|
||||||
transformReply: undefined as unknown as () => ArrayReply<BlobStringReply>
|
transformReply: undefined as unknown as () => NumberReply
|
||||||
} as const satisfies Command;
|
} as const satisfies Command;
|
||||||
|
@@ -1,28 +1,31 @@
|
|||||||
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 './PFCOUNT';
|
import PFCOUNT from './PFCOUNT';
|
||||||
|
|
||||||
describe('PFCOUNT', () => {
|
describe('PFCOUNT', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('string', () => {
|
it('string', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key'),
|
PFCOUNT.transformArguments('key'),
|
||||||
['PFCOUNT', 'key']
|
['PFCOUNT', 'key']
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
it('array', () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments(['1', '2']),
|
|
||||||
['PFCOUNT', '1', '2']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.pfCount', async client => {
|
it('array', () => {
|
||||||
assert.equal(
|
assert.deepEqual(
|
||||||
await client.pfCount('key'),
|
PFCOUNT.transformArguments(['1', '2']),
|
||||||
0
|
['PFCOUNT', '1', '2']
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
testUtils.testAll('pfCount', async client => {
|
||||||
|
assert.equal(
|
||||||
|
await client.pfCount('key'),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,28 +1,31 @@
|
|||||||
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 './PFMERGE';
|
import PFMERGE from './PFMERGE';
|
||||||
|
|
||||||
describe('PFMERGE', () => {
|
describe('PFMERGE', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('string', () => {
|
it('string', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('destination', 'source'),
|
PFMERGE.transformArguments('destination', 'source'),
|
||||||
['PFMERGE', 'destination', 'source']
|
['PFMERGE', 'destination', 'source']
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
it('array', () => {
|
|
||||||
assert.deepEqual(
|
|
||||||
transformArguments('destination', ['1', '2']),
|
|
||||||
['PFMERGE', 'destination', '1', '2']
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.pfMerge', async client => {
|
it('array', () => {
|
||||||
assert.equal(
|
assert.deepEqual(
|
||||||
await client.pfMerge('destination', 'source'),
|
PFMERGE.transformArguments('destination', ['1', '2']),
|
||||||
'OK'
|
['PFMERGE', 'destination', '1', '2']
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
testUtils.testAll('pfMerge', async client => {
|
||||||
|
assert.equal(
|
||||||
|
await client.pfMerge('{tag}destination', '{tag}source'),
|
||||||
|
'OK'
|
||||||
|
);
|
||||||
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,27 +1,22 @@
|
|||||||
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 './PSETEX';
|
import PSETEX from './PSETEX';
|
||||||
|
|
||||||
describe('PSETEX', () => {
|
describe('PSETEX', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', 1, 'value'),
|
PSETEX.transformArguments('key', 1, 'value'),
|
||||||
['PSETEX', 'key', '1', 'value']
|
['PSETEX', 'key', '1', 'value']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.pSetEx', async client => {
|
testUtils.testAll('pSetEx', async client => {
|
||||||
const a = await client.pSetEx('key', 1, 'value');
|
assert.equal(
|
||||||
assert.equal(
|
await client.pSetEx('key', 1, 'value'),
|
||||||
await client.pSetEx('key', 1, 'value'),
|
'OK'
|
||||||
'OK'
|
);
|
||||||
);
|
}, {
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
testUtils.testWithCluster('cluster.pSetEx', async cluster => {
|
});
|
||||||
assert.equal(
|
|
||||||
await cluster.pSetEx('key', 1, 'value'),
|
|
||||||
'OK'
|
|
||||||
);
|
|
||||||
}, GLOBAL.CLUSTERS.OPEN);
|
|
||||||
});
|
});
|
||||||
|
@@ -1,19 +1,22 @@
|
|||||||
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 './PTTL';
|
import PTTL from './PTTL';
|
||||||
|
|
||||||
describe('PTTL', () => {
|
describe('PTTL', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key'),
|
PTTL.transformArguments('key'),
|
||||||
['PTTL', 'key']
|
['PTTL', 'key']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.pTTL', async client => {
|
testUtils.testAll('pTTL', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.pTTL('key'),
|
await client.pTTL('key'),
|
||||||
-2
|
-2
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -91,11 +91,17 @@ import LTRIM from './LTRIM';
|
|||||||
import MGET from './MGET';
|
import MGET from './MGET';
|
||||||
import MSET from './MSET';
|
import MSET from './MSET';
|
||||||
import MSETNX from './MSETNX';
|
import MSETNX from './MSETNX';
|
||||||
|
import PERSIST from './PERSIST';
|
||||||
|
import PEXPIRE from './PEXPIRE';
|
||||||
|
import PEXPIREAT from './PEXPIREAT';
|
||||||
|
import PEXPIRETIME from './PEXPIRETIME';
|
||||||
import PFADD from './PFADD';
|
import PFADD from './PFADD';
|
||||||
import PFCOUNT from './PFCOUNT';
|
import PFCOUNT from './PFCOUNT';
|
||||||
import PFMERGE from './PFMERGE';
|
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 RANDOMKEY from './RANDOMKEY';
|
||||||
import RENAME from './RENAME';
|
import RENAME from './RENAME';
|
||||||
import RENAMENX from './RENAMENX';
|
import RENAMENX from './RENAMENX';
|
||||||
import RPOP_COUNT from './RPOP_COUNT';
|
import RPOP_COUNT from './RPOP_COUNT';
|
||||||
@@ -344,7 +350,15 @@ export default {
|
|||||||
MSET,
|
MSET,
|
||||||
mSet: MSET,
|
mSet: MSET,
|
||||||
MSETNX,
|
MSETNX,
|
||||||
mSetNx: MSETNX,
|
mSetNX: MSETNX,
|
||||||
|
PERSIST,
|
||||||
|
persist: PERSIST,
|
||||||
|
PEXPIRE,
|
||||||
|
pExpire: PEXPIRE,
|
||||||
|
PEXPIREAT,
|
||||||
|
pExpireAt: PEXPIREAT,
|
||||||
|
PEXPIRETIME,
|
||||||
|
pExpireTime: PEXPIRETIME,
|
||||||
PFADD,
|
PFADD,
|
||||||
pfAdd: PFADD,
|
pfAdd: PFADD,
|
||||||
PFCOUNT,
|
PFCOUNT,
|
||||||
@@ -358,6 +372,10 @@ export default {
|
|||||||
ping: PING,
|
ping: PING,
|
||||||
PSETEX,
|
PSETEX,
|
||||||
pSetEx: PSETEX,
|
pSetEx: PSETEX,
|
||||||
|
PTTL,
|
||||||
|
pTTL: PTTL,
|
||||||
|
RANDOMKEY,
|
||||||
|
randomKey: RANDOMKEY,
|
||||||
RENAME,
|
RENAME,
|
||||||
rename: RENAME,
|
rename: RENAME,
|
||||||
RENAMENX,
|
RENAMENX,
|
||||||
|
Reference in New Issue
Block a user