1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

Support OBJECT [...] commands (#2014)

* Support OBJECT [...] commands

* move commands to cluster/commands.ts

Co-authored-by: leibale <leibale1998@gmail.com>
This commit is contained in:
Avital Fine
2022-03-27 19:35:01 +02:00
committed by GitHub
parent 6ca45f674d
commit 515adf1346
9 changed files with 132 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './OBJECT_ENCODING';
describe('OBJECT ENCODING', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key'),
['OBJECT', 'ENCODING', 'key']
);
});
testUtils.testWithClient('client.objectEncoding', async client => {
assert.equal(
await client.objectEncoding('key'),
null
);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -0,0 +1,11 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export const FIRST_KEY_INDEX = 2;
export const IS_READ_ONLY = true;
export function transformArguments(key: RedisCommandArgument): RedisCommandArguments {
return ['OBJECT', 'ENCODING', key];
}
export declare function transformReply(): string | null;

View File

@@ -0,0 +1,19 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './OBJECT_FREQ';
describe('OBJECT FREQ', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key'),
['OBJECT', 'FREQ', 'key']
);
});
testUtils.testWithClient('client.objectFreq', async client => {
assert.equal(
await client.objectFreq('key'),
null
);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -0,0 +1,11 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export const FIRST_KEY_INDEX = 2;
export const IS_READ_ONLY = true;
export function transformArguments(key: RedisCommandArgument): RedisCommandArguments {
return ['OBJECT', 'FREQ', key];
}
export declare function transformReply(): number | null;

View File

@@ -0,0 +1,19 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './OBJECT_IDLETIME';
describe('OBJECT IDLETIME', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key'),
['OBJECT', 'IDLETIME', 'key']
);
});
testUtils.testWithClient('client.objectIdleTime', async client => {
assert.equal(
await client.objectIdleTime('key'),
null
);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -0,0 +1,11 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export const FIRST_KEY_INDEX = 2;
export const IS_READ_ONLY = true;
export function transformArguments(key: RedisCommandArgument): RedisCommandArguments {
return ['OBJECT', 'IDLETIME', key];
}
export declare function transformReply(): number | null;

View File

@@ -0,0 +1,19 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './OBJECT_REFCOUNT';
describe('OBJECT REFCOUNT', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key'),
['OBJECT', 'REFCOUNT', 'key']
);
});
testUtils.testWithClient('client.objectRefCount', async client => {
assert.equal(
await client.objectRefCount('key'),
null
);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -0,0 +1,11 @@
import { RedisCommandArgument, RedisCommandArguments } from '.';
export const FIRST_KEY_INDEX = 2;
export const IS_READ_ONLY = true;
export function transformArguments(key: RedisCommandArgument): RedisCommandArguments {
return ['OBJECT', 'REFCOUNT', key];
}
export declare function transformReply(): number | null;