diff --git a/packages/client/lib/commands/MEMORY_USAGE.spec.ts b/packages/client/lib/commands/MEMORY_USAGE.spec.ts index edf673564ee..9f14f37a704 100644 --- a/packages/client/lib/commands/MEMORY_USAGE.spec.ts +++ b/packages/client/lib/commands/MEMORY_USAGE.spec.ts @@ -20,6 +20,15 @@ describe('MEMORY USAGE', () => { ['MEMORY', 'USAGE', 'key', 'SAMPLES', '1'] ); }); + + it('with SAMPLES 0 (sample all nested values)', () => { + assert.deepEqual( + parseArgs(MEMORY_USAGE, 'key', { + SAMPLES: 0 + }), + ['MEMORY', 'USAGE', 'key', 'SAMPLES', '0'] + ); + }); }); testUtils.testWithClient('client.memoryUsage', async client => { diff --git a/packages/client/lib/commands/MEMORY_USAGE.ts b/packages/client/lib/commands/MEMORY_USAGE.ts index 6e85438dbed..ff5336d32e5 100644 --- a/packages/client/lib/commands/MEMORY_USAGE.ts +++ b/packages/client/lib/commands/MEMORY_USAGE.ts @@ -2,6 +2,10 @@ import { CommandParser } from '../client/parser'; import { NumberReply, NullReply, Command, RedisArgument } from '../RESP/types'; export interface MemoryUsageOptions { + /** + * Number of sampled nested values for aggregate types. `0` samples all of + * them; the default is 5. + */ SAMPLES?: number; } @@ -11,7 +15,7 @@ export default { parser.push('MEMORY', 'USAGE'); parser.pushKey(key); - if (options?.SAMPLES) { + if (options?.SAMPLES !== undefined) { parser.push('SAMPLES', options.SAMPLES.toString()); } },