You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
fix XSETID
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import XSETID from './XSETID';
|
||||
|
||||
describe('XSETID', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('simple', () => {
|
||||
assert.deepEqual(
|
||||
XSETID.transformArguments('key', '0-0'),
|
||||
['XSETID', 'key', '0-0']
|
||||
);
|
||||
});
|
||||
|
||||
it('with ENTRIESADDED', () => {
|
||||
assert.deepEqual(
|
||||
XSETID.transformArguments('key', '0-0', {
|
||||
ENTRIESADDED: 1
|
||||
}),
|
||||
['XSETID', 'key', '0-0', 'ENTRIESADDED', '1']
|
||||
);
|
||||
});
|
||||
|
||||
it('with MAXDELETEDID', () => {
|
||||
assert.deepEqual(
|
||||
XSETID.transformArguments('key', '0-0', {
|
||||
MAXDELETEDID: '1-1'
|
||||
}),
|
||||
['XSETID', 'key', '0-0', 'MAXDELETEDID', '1-1']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testAll('xSetId', async client => {
|
||||
assert.deepEqual(
|
||||
await client.xSetId('key', '0-0'),
|
||||
[]
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
@@ -1,28 +1,29 @@
|
||||
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { RedisArgument, SimpleStringReply, Command } from '../RESP/types';
|
||||
export interface XSetIdOptions {
|
||||
ENTRIESADDED?: number;
|
||||
MAXDELETEDID?: RedisArgument;
|
||||
}
|
||||
|
||||
// export const FIRST_KEY_INDEX = 1;
|
||||
export default {
|
||||
FIRST_KEY_INDEX: 1,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(
|
||||
key: RedisArgument,
|
||||
lastId: RedisArgument,
|
||||
options?: XSetIdOptions
|
||||
) {
|
||||
const args = ['XSETID', key, lastId];
|
||||
|
||||
// interface XSetIdOptions {
|
||||
// ENTRIESADDED?: number;
|
||||
// MAXDELETEDID?: RedisCommandArgument;
|
||||
// }
|
||||
if (options?.ENTRIESADDED) {
|
||||
args.push('ENTRIESADDED', options.ENTRIESADDED.toString());
|
||||
}
|
||||
|
||||
// export function transformArguments(
|
||||
// key: RedisCommandArgument,
|
||||
// lastId: RedisCommandArgument,
|
||||
// options?: XSetIdOptions
|
||||
// ): RedisCommandArguments {
|
||||
// const args = ['XSETID', key, lastId];
|
||||
if (options?.MAXDELETEDID) {
|
||||
args.push('MAXDELETEDID', options.MAXDELETEDID);
|
||||
}
|
||||
|
||||
// if (options?.ENTRIESADDED) {
|
||||
// args.push('ENTRIESADDED', options.ENTRIESADDED.toString());
|
||||
// }
|
||||
return args;
|
||||
},
|
||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||
} as const satisfies Command;
|
||||
|
||||
// if (options?.MAXDELETEDID) {
|
||||
// args.push('MAXDELETEDID', options.MAXDELETEDID);
|
||||
// }
|
||||
|
||||
// return args;
|
||||
// }
|
||||
|
||||
// export declare function transformReply(): 'OK';
|
||||
|
@@ -145,6 +145,7 @@ import XACK from './XACK';
|
||||
import XADD_NOMKSTREAM from './XADD_NOMKSTREAM';
|
||||
import XADD from './XADD';
|
||||
import XDEL from './XDEL';
|
||||
import XSETID from './XSETID';
|
||||
import XTRIM from './XTRIM';
|
||||
import XLEN from './XLEN';
|
||||
import ZADD from './ZADD';
|
||||
@@ -467,6 +468,8 @@ export default {
|
||||
xAdd: XADD,
|
||||
XDEL,
|
||||
xDel: XDEL,
|
||||
XSETID,
|
||||
xSetId: XSETID,
|
||||
XTRIM,
|
||||
xTrim: XTRIM,
|
||||
XLEN,
|
||||
|
Reference in New Issue
Block a user