1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

fix: zero ttl is ignored (#2349)

* fix: zero ttl is ignored

* Update SET.ts

* Update SET.ts

Co-authored-by: Leibale Eidelman <me@leibale.com>
This commit is contained in:
Vojtech Novak
2022-12-15 18:04:13 +01:00
committed by GitHub
parent ce1b8f7f4e
commit f6093b7b0f
2 changed files with 14 additions and 14 deletions

View File

@@ -13,8 +13,8 @@ describe('SET', () => {
it('number', () => {
assert.deepEqual(
transformArguments('key', 1),
['SET', 'key', '1']
transformArguments('key', 0),
['SET', 'key', '0']
);
});
@@ -22,36 +22,36 @@ describe('SET', () => {
it('with EX', () => {
assert.deepEqual(
transformArguments('key', 'value', {
EX: 1
EX: 0
}),
['SET', 'key', 'value', 'EX', '1']
['SET', 'key', 'value', 'EX', '0']
);
});
it('with PX', () => {
assert.deepEqual(
transformArguments('key', 'value', {
PX: 1
PX: 0
}),
['SET', 'key', 'value', 'PX', '1']
['SET', 'key', 'value', 'PX', '0']
);
});
it('with EXAT', () => {
assert.deepEqual(
transformArguments('key', 'value', {
EXAT: 1
EXAT: 0
}),
['SET', 'key', 'value', 'EXAT', '1']
['SET', 'key', 'value', 'EXAT', '0']
);
});
it('with PXAT', () => {
assert.deepEqual(
transformArguments('key', 'value', {
PXAT: 1
PXAT: 0
}),
['SET', 'key', 'value', 'PXAT', '1']
['SET', 'key', 'value', 'PXAT', '0']
);
});

View File

@@ -35,13 +35,13 @@ export function transformArguments(
typeof value === 'number' ? value.toString() : value
];
if (options?.EX) {
if (options?.EX !== undefined) {
args.push('EX', options.EX.toString());
} else if (options?.PX) {
} else if (options?.PX !== undefined) {
args.push('PX', options.PX.toString());
} else if (options?.EXAT) {
} else if (options?.EXAT !== undefined) {
args.push('EXAT', options.EXAT.toString());
} else if (options?.PXAT) {
} else if (options?.PXAT !== undefined) {
args.push('PXAT', options.PXAT.toString());
} else if (options?.KEEPTTL) {
args.push('KEEPTTL');