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 XTRIM
This commit is contained in:
@@ -1,49 +1,52 @@
|
|||||||
// 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 './XTRIM';
|
import XTRIM from './XTRIM';
|
||||||
|
|
||||||
// describe('XTRIM', () => {
|
describe('XTRIM', () => {
|
||||||
// describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
// it('simple', () => {
|
it('simple', () => {
|
||||||
// assert.deepEqual(
|
assert.deepEqual(
|
||||||
// transformArguments('key', 'MAXLEN', 1),
|
XTRIM.transformArguments('key', 'MAXLEN', 1),
|
||||||
// ['XTRIM', 'key', 'MAXLEN', '1']
|
['XTRIM', 'key', 'MAXLEN', '1']
|
||||||
// );
|
);
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it('with strategyModifier', () => {
|
it('with strategyModifier', () => {
|
||||||
// assert.deepEqual(
|
assert.deepEqual(
|
||||||
// transformArguments('key', 'MAXLEN', 1, {
|
XTRIM.transformArguments('key', 'MAXLEN', 1, {
|
||||||
// strategyModifier: '='
|
strategyModifier: '='
|
||||||
// }),
|
}),
|
||||||
// ['XTRIM', 'key', 'MAXLEN', '=', '1']
|
['XTRIM', 'key', 'MAXLEN', '=', '1']
|
||||||
// );
|
);
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it('with LIMIT', () => {
|
it('with LIMIT', () => {
|
||||||
// assert.deepEqual(
|
assert.deepEqual(
|
||||||
// transformArguments('key', 'MAXLEN', 1, {
|
XTRIM.transformArguments('key', 'MAXLEN', 1, {
|
||||||
// LIMIT: 1
|
LIMIT: 1
|
||||||
// }),
|
}),
|
||||||
// ['XTRIM', 'key', 'MAXLEN', '1', 'LIMIT', '1']
|
['XTRIM', 'key', 'MAXLEN', '1', 'LIMIT', '1']
|
||||||
// );
|
);
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it('with strategyModifier, LIMIT', () => {
|
it('with strategyModifier, LIMIT', () => {
|
||||||
// assert.deepEqual(
|
assert.deepEqual(
|
||||||
// transformArguments('key', 'MAXLEN', 1, {
|
XTRIM.transformArguments('key', 'MAXLEN', 1, {
|
||||||
// strategyModifier: '=',
|
strategyModifier: '=',
|
||||||
// LIMIT: 1
|
LIMIT: 1
|
||||||
// }),
|
}),
|
||||||
// ['XTRIM', 'key', 'MAXLEN', '=', '1', 'LIMIT', '1']
|
['XTRIM', 'key', 'MAXLEN', '=', '1', 'LIMIT', '1']
|
||||||
// );
|
);
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// testUtils.testWithClient('client.xTrim', async client => {
|
testUtils.testAll('xTrim', async client => {
|
||||||
// assert.equal(
|
assert.equal(
|
||||||
// await client.xTrim('key', 'MAXLEN', 1),
|
await client.xTrim('key', 'MAXLEN', 1),
|
||||||
// 0
|
0
|
||||||
// );
|
);
|
||||||
// }, GLOBAL.SERVERS.OPEN);
|
}, {
|
||||||
// });
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@@ -1,31 +1,31 @@
|
|||||||
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
import { NumberReply, Command, RedisArgument } from '../RESP/types';
|
||||||
|
|
||||||
// export const FIRST_KEY_INDEX = 1;
|
export interface XTrimOptions {
|
||||||
|
strategyModifier?: '=' | '~';
|
||||||
|
LIMIT?: number;
|
||||||
|
}
|
||||||
|
|
||||||
// interface XTrimOptions {
|
export default {
|
||||||
// strategyModifier?: '=' | '~';
|
FIRST_KEY_INDEX: 1,
|
||||||
// LIMIT?: number;
|
IS_READ_ONLY: false,
|
||||||
// }
|
transformArguments(
|
||||||
|
key: RedisArgument,
|
||||||
|
strategy: 'MAXLEN' | 'MINID',
|
||||||
|
threshold: number,
|
||||||
|
options?: XTrimOptions) {
|
||||||
|
const args = ['XTRIM', key, strategy];
|
||||||
|
|
||||||
// export function transformArguments(
|
if (options?.strategyModifier) {
|
||||||
// key: RedisCommandArgument,
|
args.push(options.strategyModifier);
|
||||||
// strategy: 'MAXLEN' | 'MINID',
|
}
|
||||||
// threshold: number,
|
|
||||||
// options?: XTrimOptions
|
|
||||||
// ): RedisCommandArguments {
|
|
||||||
// const args = ['XTRIM', key, strategy];
|
|
||||||
|
|
||||||
// if (options?.strategyModifier) {
|
args.push(threshold.toString());
|
||||||
// args.push(options.strategyModifier);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// args.push(threshold.toString());
|
if (options?.LIMIT) {
|
||||||
|
args.push('LIMIT', options.LIMIT.toString());
|
||||||
|
}
|
||||||
|
|
||||||
// if (options?.LIMIT) {
|
return args;
|
||||||
// args.push('LIMIT', options.LIMIT.toString());
|
},
|
||||||
// }
|
transformReply: undefined as unknown as () => NumberReply
|
||||||
|
} as const satisfies Command;
|
||||||
// return args;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// export declare function transformReply(): number;
|
|
||||||
|
@@ -144,7 +144,8 @@ import WATCH from './WATCH';
|
|||||||
import XACK from './XACK';
|
import XACK from './XACK';
|
||||||
import XADD_NOMKSTREAM from './XADD_NOMKSTREAM';
|
import XADD_NOMKSTREAM from './XADD_NOMKSTREAM';
|
||||||
import XADD from './XADD';
|
import XADD from './XADD';
|
||||||
import XDEL from './XDEL'
|
import XDEL from './XDEL';
|
||||||
|
import XTRIM from './XTRIM';
|
||||||
import XLEN from './XLEN';
|
import XLEN from './XLEN';
|
||||||
import ZADD from './ZADD';
|
import ZADD from './ZADD';
|
||||||
import ZCARD from './ZCARD';
|
import ZCARD from './ZCARD';
|
||||||
@@ -466,7 +467,8 @@ export default {
|
|||||||
xAdd: XADD,
|
xAdd: XADD,
|
||||||
XDEL,
|
XDEL,
|
||||||
xDel: XDEL,
|
xDel: XDEL,
|
||||||
|
XTRIM,
|
||||||
|
xTrim: XTRIM,
|
||||||
XLEN,
|
XLEN,
|
||||||
xLen: XLEN,
|
xLen: XLEN,
|
||||||
ZADD,
|
ZADD,
|
||||||
|
Reference in New Issue
Block a user