Skip to content

Commit 85d5bf4

Browse files
sjpotterleibale
andauthored
add CLIENT KILL MAXAGE (v5) (#2760)
* add CLIENT KILL MANAGE maxAge (v5) * replace "MANAGE" with "MAXAGE" * fix test --------- Co-authored-by: Leibale Eidelman <[email protected]>
1 parent 271baf3 commit 85d5bf4

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ describe('CLIENT KILL', () => {
6565
);
6666
});
6767

68+
it('MAXAGE', () => {
69+
assert.deepEqual(
70+
CLIENT_KILL.transformArguments({
71+
filter: CLIENT_KILL_FILTERS.MAXAGE,
72+
maxAge: 10
73+
}),
74+
['CLIENT', 'KILL', 'MAXAGE', '10']
75+
);
76+
});
77+
6878
describe('SKIP_ME', () => {
6979
it('undefined', () => {
7080
assert.deepEqual(

packages/client/lib/commands/CLIENT_KILL.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export const CLIENT_KILL_FILTERS = {
66
ID: 'ID',
77
TYPE: 'TYPE',
88
USER: 'USER',
9-
SKIP_ME: 'SKIPME'
9+
SKIP_ME: 'SKIPME',
10+
MAXAGE: 'MAXAGE'
1011
} as const;
1112

1213
type CLIENT_KILL_FILTERS = typeof CLIENT_KILL_FILTERS;
@@ -39,7 +40,11 @@ export type ClientKillSkipMe = CLIENT_KILL_FILTERS['SKIP_ME'] | (ClientKillFilte
3940
skipMe: boolean;
4041
});
4142

42-
export type ClientKillFilter = ClientKillAddress | ClientKillLocalAddress | ClientKillId | ClientKillType | ClientKillUser | ClientKillSkipMe;
43+
export interface ClientKillMaxAge extends ClientKillFilterCommon<CLIENT_KILL_FILTERS['MANAGE']> {
44+
maxAge: number;
45+
}
46+
47+
export type ClientKillFilter = ClientKillAddress | ClientKillLocalAddress | ClientKillId | ClientKillType | ClientKillUser | ClientKillSkipMe | ClientKillMaxAge;
4348

4449
export default {
4550
FIRST_KEY_INDEX: undefined,
@@ -96,5 +101,9 @@ function pushFilter(args: Array<RedisArgument>, filter: ClientKillFilter): void
96101
case CLIENT_KILL_FILTERS.SKIP_ME:
97102
args.push(filter.skipMe ? 'yes' : 'no');
98103
break;
104+
105+
case CLIENT_KILL_FILTERS.MAXAGE:
106+
args.push(filter.maxAge.toString());
107+
break;
99108
}
100109
}

0 commit comments

Comments
 (0)