Skip to content

Commit 515adf1

Browse files
Avital-Fineleibale
andauthored
Support OBJECT [...] commands (#2014)
* Support OBJECT [...] commands * move commands to cluster/commands.ts Co-authored-by: leibale <[email protected]>
1 parent 6ca45f6 commit 515adf1

File tree

9 files changed

+132
-0
lines changed

9 files changed

+132
-0
lines changed

packages/client/lib/cluster/commands.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ import * as MGET from '../commands/MGET';
7373
import * as MIGRATE from '../commands/MIGRATE';
7474
import * as MSET from '../commands/MSET';
7575
import * as MSETNX from '../commands/MSETNX';
76+
import * as OBJECT_ENCODING from '../commands/OBJECT_ENCODING';
77+
import * as OBJECT_FREQ from '../commands/OBJECT_FREQ';
78+
import * as OBJECT_IDLETIME from '../commands/OBJECT_IDLETIME';
79+
import * as OBJECT_REFCOUNT from '../commands/OBJECT_REFCOUNT';
7680
import * as PERSIST from '../commands/PERSIST';
7781
import * as PEXPIRE from '../commands/PEXPIRE';
7882
import * as PEXPIREAT from '../commands/PEXPIREAT';
@@ -330,6 +334,14 @@ export default {
330334
mSet: MSET,
331335
MSETNX,
332336
mSetNX: MSETNX,
337+
OBJECT_ENCODING,
338+
objectEncoding: OBJECT_ENCODING,
339+
OBJECT_FREQ,
340+
objectFreq: OBJECT_FREQ,
341+
OBJECT_IDLETIME,
342+
objectIdleTime: OBJECT_IDLETIME,
343+
OBJECT_REFCOUNT,
344+
objectRefCount: OBJECT_REFCOUNT,
333345
PERSIST,
334346
persist: PERSIST,
335347
PEXPIRE,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { strict as assert } from 'assert';
2+
import testUtils, { GLOBAL } from '../test-utils';
3+
import { transformArguments } from './OBJECT_ENCODING';
4+
5+
describe('OBJECT ENCODING', () => {
6+
it('transformArguments', () => {
7+
assert.deepEqual(
8+
transformArguments('key'),
9+
['OBJECT', 'ENCODING', 'key']
10+
);
11+
});
12+
13+
testUtils.testWithClient('client.objectEncoding', async client => {
14+
assert.equal(
15+
await client.objectEncoding('key'),
16+
null
17+
);
18+
}, GLOBAL.SERVERS.OPEN);
19+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { RedisCommandArgument, RedisCommandArguments } from '.';
2+
3+
export const FIRST_KEY_INDEX = 2;
4+
5+
export const IS_READ_ONLY = true;
6+
7+
export function transformArguments(key: RedisCommandArgument): RedisCommandArguments {
8+
return ['OBJECT', 'ENCODING', key];
9+
}
10+
11+
export declare function transformReply(): string | null;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { strict as assert } from 'assert';
2+
import testUtils, { GLOBAL } from '../test-utils';
3+
import { transformArguments } from './OBJECT_FREQ';
4+
5+
describe('OBJECT FREQ', () => {
6+
it('transformArguments', () => {
7+
assert.deepEqual(
8+
transformArguments('key'),
9+
['OBJECT', 'FREQ', 'key']
10+
);
11+
});
12+
13+
testUtils.testWithClient('client.objectFreq', async client => {
14+
assert.equal(
15+
await client.objectFreq('key'),
16+
null
17+
);
18+
}, GLOBAL.SERVERS.OPEN);
19+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { RedisCommandArgument, RedisCommandArguments } from '.';
2+
3+
export const FIRST_KEY_INDEX = 2;
4+
5+
export const IS_READ_ONLY = true;
6+
7+
export function transformArguments(key: RedisCommandArgument): RedisCommandArguments {
8+
return ['OBJECT', 'FREQ', key];
9+
}
10+
11+
export declare function transformReply(): number | null;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { strict as assert } from 'assert';
2+
import testUtils, { GLOBAL } from '../test-utils';
3+
import { transformArguments } from './OBJECT_IDLETIME';
4+
5+
describe('OBJECT IDLETIME', () => {
6+
it('transformArguments', () => {
7+
assert.deepEqual(
8+
transformArguments('key'),
9+
['OBJECT', 'IDLETIME', 'key']
10+
);
11+
});
12+
13+
testUtils.testWithClient('client.objectIdleTime', async client => {
14+
assert.equal(
15+
await client.objectIdleTime('key'),
16+
null
17+
);
18+
}, GLOBAL.SERVERS.OPEN);
19+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { RedisCommandArgument, RedisCommandArguments } from '.';
2+
3+
export const FIRST_KEY_INDEX = 2;
4+
5+
export const IS_READ_ONLY = true;
6+
7+
export function transformArguments(key: RedisCommandArgument): RedisCommandArguments {
8+
return ['OBJECT', 'IDLETIME', key];
9+
}
10+
11+
export declare function transformReply(): number | null;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { strict as assert } from 'assert';
2+
import testUtils, { GLOBAL } from '../test-utils';
3+
import { transformArguments } from './OBJECT_REFCOUNT';
4+
5+
describe('OBJECT REFCOUNT', () => {
6+
it('transformArguments', () => {
7+
assert.deepEqual(
8+
transformArguments('key'),
9+
['OBJECT', 'REFCOUNT', 'key']
10+
);
11+
});
12+
13+
testUtils.testWithClient('client.objectRefCount', async client => {
14+
assert.equal(
15+
await client.objectRefCount('key'),
16+
null
17+
);
18+
}, GLOBAL.SERVERS.OPEN);
19+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { RedisCommandArgument, RedisCommandArguments } from '.';
2+
3+
export const FIRST_KEY_INDEX = 2;
4+
5+
export const IS_READ_ONLY = true;
6+
7+
export function transformArguments(key: RedisCommandArgument): RedisCommandArguments {
8+
return ['OBJECT', 'REFCOUNT', key];
9+
}
10+
11+
export declare function transformReply(): number | null;

0 commit comments

Comments
 (0)