Skip to content

Commit f6093b7

Browse files
vonovakleibale
andauthored
fix: zero ttl is ignored (#2349)
* fix: zero ttl is ignored * Update SET.ts * Update SET.ts Co-authored-by: Leibale Eidelman <[email protected]>
1 parent ce1b8f7 commit f6093b7

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

packages/client/lib/commands/SET.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,45 @@ describe('SET', () => {
1313

1414
it('number', () => {
1515
assert.deepEqual(
16-
transformArguments('key', 1),
17-
['SET', 'key', '1']
16+
transformArguments('key', 0),
17+
['SET', 'key', '0']
1818
);
1919
});
2020

2121
describe('TTL', () => {
2222
it('with EX', () => {
2323
assert.deepEqual(
2424
transformArguments('key', 'value', {
25-
EX: 1
25+
EX: 0
2626
}),
27-
['SET', 'key', 'value', 'EX', '1']
27+
['SET', 'key', 'value', 'EX', '0']
2828
);
2929
});
3030

3131
it('with PX', () => {
3232
assert.deepEqual(
3333
transformArguments('key', 'value', {
34-
PX: 1
34+
PX: 0
3535
}),
36-
['SET', 'key', 'value', 'PX', '1']
36+
['SET', 'key', 'value', 'PX', '0']
3737
);
3838
});
3939

4040
it('with EXAT', () => {
4141
assert.deepEqual(
4242
transformArguments('key', 'value', {
43-
EXAT: 1
43+
EXAT: 0
4444
}),
45-
['SET', 'key', 'value', 'EXAT', '1']
45+
['SET', 'key', 'value', 'EXAT', '0']
4646
);
4747
});
4848

4949
it('with PXAT', () => {
5050
assert.deepEqual(
5151
transformArguments('key', 'value', {
52-
PXAT: 1
52+
PXAT: 0
5353
}),
54-
['SET', 'key', 'value', 'PXAT', '1']
54+
['SET', 'key', 'value', 'PXAT', '0']
5555
);
5656
});
5757

packages/client/lib/commands/SET.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ export function transformArguments(
3535
typeof value === 'number' ? value.toString() : value
3636
];
3737

38-
if (options?.EX) {
38+
if (options?.EX !== undefined) {
3939
args.push('EX', options.EX.toString());
40-
} else if (options?.PX) {
40+
} else if (options?.PX !== undefined) {
4141
args.push('PX', options.PX.toString());
42-
} else if (options?.EXAT) {
42+
} else if (options?.EXAT !== undefined) {
4343
args.push('EXAT', options.EXAT.toString());
44-
} else if (options?.PXAT) {
44+
} else if (options?.PXAT !== undefined) {
4545
args.push('PXAT', options.PXAT.toString());
4646
} else if (options?.KEEPTTL) {
4747
args.push('KEEPTTL');

0 commit comments

Comments
 (0)