From 53a96ccce4508b4435e8832626e6acccf4243fda Mon Sep 17 00:00:00 2001 From: Leibale Eidelman Date: Wed, 11 May 2022 09:36:23 -0400 Subject: [PATCH] fix #1911 - CLIENT NO-EVICT (#2124) --- packages/client/lib/client/commands.ts | 3 ++ .../lib/commands/CLIENT_NO-EVICT.spec.ts | 30 +++++++++++++++++++ .../client/lib/commands/CLIENT_NO-EVICT.ts | 11 +++++++ 3 files changed, 44 insertions(+) create mode 100644 packages/client/lib/commands/CLIENT_NO-EVICT.spec.ts create mode 100644 packages/client/lib/commands/CLIENT_NO-EVICT.ts diff --git a/packages/client/lib/client/commands.ts b/packages/client/lib/client/commands.ts index f591ec2041..c5c11ceaa2 100644 --- a/packages/client/lib/client/commands.ts +++ b/packages/client/lib/client/commands.ts @@ -21,6 +21,7 @@ import * as CLIENT_GETNAME from '../commands/CLIENT_GETNAME'; import * as CLIENT_GETREDIR from '../commands/CLIENT_GETREDIR'; import * as CLIENT_ID from '../commands/CLIENT_ID'; import * as CLIENT_KILL from '../commands/CLIENT_KILL'; +import * as CLIENT_NO_EVICT from '../commands/CLIENT_NO-EVICT'; import * as CLIENT_SETNAME from '../commands/CLIENT_SETNAME'; import * as CLIENT_INFO from '../commands/CLIENT_INFO'; import * as CLUSTER_ADDSLOTS from '../commands/CLUSTER_ADDSLOTS'; @@ -158,6 +159,8 @@ export default { clientKill: CLIENT_KILL, CLIENT_SETNAME, clientSetName: CLIENT_SETNAME, + 'CLIENT_NO-EVICT': CLIENT_NO_EVICT, + clientNoEvict: CLIENT_NO_EVICT, CLIENT_INFO, clientInfo: CLIENT_INFO, CLUSTER_ADDSLOTS, diff --git a/packages/client/lib/commands/CLIENT_NO-EVICT.spec.ts b/packages/client/lib/commands/CLIENT_NO-EVICT.spec.ts new file mode 100644 index 0000000000..df8903f064 --- /dev/null +++ b/packages/client/lib/commands/CLIENT_NO-EVICT.spec.ts @@ -0,0 +1,30 @@ +import { strict as assert } from 'assert'; +import testUtils, { GLOBAL } from '../test-utils'; +import { transformArguments } from './CLIENT_NO-EVICT'; + +describe('CLIENT NO-EVICT', () => { + testUtils.isVersionGreaterThanHook([7]); + + describe('transformArguments', () => { + it('true', () => { + assert.deepEqual( + transformArguments(true), + ['CLIENT', 'NO-EVICT', 'ON'] + ); + }); + + it('false', () => { + assert.deepEqual( + transformArguments(false), + ['CLIENT', 'NO-EVICT', 'OFF'] + ); + }); + }); + + testUtils.testWithClient('client.clientNoEvict', async client => { + assert.equal( + await client.clientNoEvict(true), + 'OK' + ); + }, GLOBAL.SERVERS.OPEN); +}); diff --git a/packages/client/lib/commands/CLIENT_NO-EVICT.ts b/packages/client/lib/commands/CLIENT_NO-EVICT.ts new file mode 100644 index 0000000000..86edbde1d2 --- /dev/null +++ b/packages/client/lib/commands/CLIENT_NO-EVICT.ts @@ -0,0 +1,11 @@ +import { RedisCommandArguments } from '.'; + +export function transformArguments(value: boolean): RedisCommandArguments { + return [ + 'CLIENT', + 'NO-EVICT', + value ? 'ON' : 'OFF' + ]; +} + +export declare function transformReply(): 'OK' | Buffer;