From 103026b689dd03d364d5b511332c9b7a61370f32 Mon Sep 17 00:00:00 2001 From: codrin-ch Date: Wed, 3 May 2023 12:44:22 +0300 Subject: [PATCH] Add support for new redis command CLIENT NO-TOUCH --- packages/client/lib/client/commands.ts | 3 ++ .../lib/commands/CLIENT_NO-TOUCH.spec.ts | 30 +++++++++++++++++++ .../client/lib/commands/CLIENT_NO-TOUCH.ts | 11 +++++++ 3 files changed, 44 insertions(+) create mode 100644 packages/client/lib/commands/CLIENT_NO-TOUCH.spec.ts create mode 100644 packages/client/lib/commands/CLIENT_NO-TOUCH.ts diff --git a/packages/client/lib/client/commands.ts b/packages/client/lib/client/commands.ts index 2605962432a..ac1350e7844 100644 --- a/packages/client/lib/client/commands.ts +++ b/packages/client/lib/client/commands.ts @@ -23,6 +23,7 @@ import * as CLIENT_ID from '../commands/CLIENT_ID'; import * as CLIENT_KILL from '../commands/CLIENT_KILL'; import * as CLIENT_LIST from '../commands/CLIENT_LIST'; import * as CLIENT_NO_EVICT from '../commands/CLIENT_NO-EVICT'; +import * as CLIENT_NO_TOUCH from '../commands/CLIENT_NO-TOUCH'; import * as CLIENT_PAUSE from '../commands/CLIENT_PAUSE'; import * as CLIENT_SETNAME from '../commands/CLIENT_SETNAME'; import * as CLIENT_TRACKING from '../commands/CLIENT_TRACKING'; @@ -166,6 +167,8 @@ export default { clientKill: CLIENT_KILL, 'CLIENT_NO-EVICT': CLIENT_NO_EVICT, clientNoEvict: CLIENT_NO_EVICT, + 'CLIENT_NO-TOUCH': CLIENT_NO_TOUCH, + clientNoTouch: CLIENT_NO_TOUCH, CLIENT_LIST, clientList: CLIENT_LIST, CLIENT_PAUSE, diff --git a/packages/client/lib/commands/CLIENT_NO-TOUCH.spec.ts b/packages/client/lib/commands/CLIENT_NO-TOUCH.spec.ts new file mode 100644 index 00000000000..80ee0ada1fd --- /dev/null +++ b/packages/client/lib/commands/CLIENT_NO-TOUCH.spec.ts @@ -0,0 +1,30 @@ +import { strict as assert } from 'assert'; +import testUtils, { GLOBAL } from '../test-utils'; +import { transformArguments } from './CLIENT_NO-TOUCH'; + +describe('CLIENT NO-TOUCH', () => { + testUtils.isVersionGreaterThanHook([7, 2]); + + describe('transformArguments', () => { + it('true', () => { + assert.deepEqual( + transformArguments(true), + ['CLIENT', 'NO-TOUCH', 'ON'] + ); + }); + + it('false', () => { + assert.deepEqual( + transformArguments(false), + ['CLIENT', 'NO-TOUCH', 'OFF'] + ); + }); + }); + + testUtils.testWithClient('client.clientNoTouch', async client => { + assert.equal( + await client.clientNoTouch(true), + 'OK' + ); + }, GLOBAL.SERVERS.OPEN); +}); diff --git a/packages/client/lib/commands/CLIENT_NO-TOUCH.ts b/packages/client/lib/commands/CLIENT_NO-TOUCH.ts new file mode 100644 index 00000000000..d11f693dbab --- /dev/null +++ b/packages/client/lib/commands/CLIENT_NO-TOUCH.ts @@ -0,0 +1,11 @@ +import { RedisCommandArguments } from '.'; + +export function transformArguments(value: boolean): RedisCommandArguments { + return [ + 'CLIENT', + 'NO-TOUCH', + value ? 'ON' : 'OFF' + ]; +} + +export declare function transformReply(): 'OK' | Buffer;