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

"forward port" changes from 4.6.9

This commit is contained in:
Leibale
2023-09-19 19:23:24 -04:00
parent 819ca71538
commit 099f16e45f
16 changed files with 306 additions and 260 deletions

View File

@@ -1,22 +1,26 @@
// This example demonstrates the use of the DUMP and RESTORE commands // This example demonstrates the use of the DUMP and RESTORE commands
import { commandOptions, createClient } from 'redis'; import { createClient, RESP_TYPES } from 'redis';
const client = createClient(); const client = await createClient({
await client.connect(); commandOptions: {
typeMapping: {
[RESP_TYPES.BLOB_STRING]: Buffer
}
}
}).on('error', err => {
console.log('Redis Client Error', err);
}).connect();
// DUMP a specific key into a local variable // DUMP a specific key into a local variable
const dump = await client.dump( const dump = await client.dump('source');
commandOptions({ returnBuffers: true }),
'source'
);
// RESTORE into a new key // RESTORE into a new key
await client.restore('destination', 0, dump); await client.restore('destination', 0, dump);
// RESTORE and REPLACE an existing key // RESTORE and REPLACE an existing key
await client.restore('destination', 0, dump, { await client.restore('destination', 0, dump, {
REPLACE: true REPLACE: true
}); });
await client.quit(); await client.close();

View File

@@ -1,30 +1,30 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './CLIENT_NO-TOUCH'; import CLIENT_NO_TOUCH from './CLIENT_NO-TOUCH';
describe('CLIENT NO-TOUCH', () => { describe('CLIENT NO-TOUCH', () => {
testUtils.isVersionGreaterThanHook([7, 2]); testUtils.isVersionGreaterThanHook([7, 2]);
describe('transformArguments', () => { describe('transformArguments', () => {
it('true', () => { it('true', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(true), CLIENT_NO_TOUCH.transformArguments(true),
['CLIENT', 'NO-TOUCH', 'ON'] ['CLIENT', 'NO-TOUCH', 'ON']
); );
});
it('false', () => {
assert.deepEqual(
transformArguments(false),
['CLIENT', 'NO-TOUCH', 'OFF']
);
});
}); });
testUtils.testWithClient('client.clientNoTouch', async client => { it('false', () => {
assert.equal( assert.deepEqual(
await client.clientNoTouch(true), CLIENT_NO_TOUCH.transformArguments(false),
'OK' ['CLIENT', 'NO-TOUCH', 'OFF']
); );
}, GLOBAL.SERVERS.OPEN); });
});
testUtils.testWithClient('client.clientNoTouch', async client => {
assert.equal(
await client.clientNoTouch(true),
'OK'
);
}, GLOBAL.SERVERS.OPEN);
}); });

View File

@@ -1,11 +1,15 @@
import { RedisCommandArguments } from '.'; import { SimpleStringReply, Command } from '@redis/client/dist/lib/RESP/types';
export function transformArguments(value: boolean): RedisCommandArguments { export default {
FIRST_KEY_INDEX: undefined,
IS_READ_ONLY: true,
transformArguments(value: boolean) {
return [ return [
'CLIENT', 'CLIENT',
'NO-TOUCH', 'NO-TOUCH',
value ? 'ON' : 'OFF' value ? 'ON' : 'OFF'
]; ];
} },
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
} as const satisfies Command;
export declare function transformReply(): 'OK' | Buffer;

View File

@@ -1,22 +1,22 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './CLUSTER_MYSHARDID'; import CLUSTER_MYSHARDID from './CLUSTER_MYSHARDID';
describe('CLUSTER MYSHARDID', () => { describe('CLUSTER MYSHARDID', () => {
testUtils.isVersionGreaterThanHook([7, 2]); testUtils.isVersionGreaterThanHook([7, 2]);
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(), CLUSTER_MYSHARDID.transformArguments(),
['CLUSTER', 'MYSHARDID'] ['CLUSTER', 'MYSHARDID']
); );
}); });
testUtils.testWithCluster('clusterNode.clusterMyShardId', async cluster => { testUtils.testWithCluster('clusterNode.clusterMyShardId', async cluster => {
const client = await cluster.nodeClient(cluster.masters[0]); const client = await cluster.nodeClient(cluster.masters[0]);
assert.equal( assert.equal(
typeof await client.clusterMyShardId(), typeof await client.clusterMyShardId(),
'string' 'string'
); );
}, GLOBAL.CLUSTERS.OPEN); }, GLOBAL.CLUSTERS.OPEN);
}); });

View File

@@ -1,7 +1,11 @@
export const IS_READ_ONLY = true; import { BlobStringReply, Command } from '@redis/client/dist/lib/RESP/types';
export function transformArguments() { export default {
FIRST_KEY_INDEX: undefined,
IS_READ_ONLY: true,
transformArguments() {
return ['CLUSTER', 'MYSHARDID']; return ['CLUSTER', 'MYSHARDID'];
} },
transformReply: undefined as unknown as () => BlobStringReply
} as const satisfies Command;
export declare function transformReply(): string | Buffer;

View File

@@ -15,14 +15,12 @@ describe('LATENCY GRAPH', () => {
}); });
testUtils.testWithClient('client.latencyGraph', async client => { testUtils.testWithClient('client.latencyGraph', async client => {
await Promise.all([ const [,, reply] = await Promise.all([
client.configSet('latency-monitor-threshold', '1'), client.configSet('latency-monitor-threshold', '1'),
client.sendCommand(['DEBUG', 'SLEEP', '0.001']) client.sendCommand(['DEBUG', 'SLEEP', '0.001']),
client.latencyGraph('command')
]); ]);
assert.equal( assert.equal(typeof reply, 'string');
typeof await client.latencyGraph('command'),
'string'
);
}, GLOBAL.SERVERS.OPEN); }, GLOBAL.SERVERS.OPEN);
}); });

View File

@@ -1,4 +1,4 @@
import { SimpleStringReply, Command, BlobStringReply } from '../RESP/types'; import { BlobStringReply, Command } from '../RESP/types';
export const LATENCY_EVENTS = { export const LATENCY_EVENTS = {
ACTIVE_DEFRAG_CYCLE: 'active-defrag-cycle', ACTIVE_DEFRAG_CYCLE: 'active-defrag-cycle',

View File

@@ -1,26 +1,26 @@
import {strict as assert} from 'assert'; import { strict as assert } from 'assert';
import testUtils, {GLOBAL} from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LATENCY_HISTORY'; import LATENCY_HISTORY from './LATENCY_HISTORY';
describe('LATENCY HISTORY', () => { describe('LATENCY HISTORY', () => {
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('command'), LATENCY_HISTORY.transformArguments('command'),
['LATENCY', 'HISTORY', 'command'] ['LATENCY', 'HISTORY', 'command']
); );
}); });
testUtils.testWithClient('client.latencyHistory', async client => { testUtils.testWithClient('client.latencyHistory', async client => {
await Promise.all([ const [,, reply] = await Promise.all([
client.configSet('latency-monitor-threshold', '100'), client.configSet('latency-monitor-threshold', '100'),
client.sendCommand(['DEBUG', 'SLEEP', '1']) client.sendCommand(['DEBUG', 'SLEEP', '1']),
]); client.latencyHistory('command')
]);
const latencyHisRes = await client.latencyHistory('command');
assert.ok(Array.isArray(latencyHisRes)); assert.ok(Array.isArray(reply));
for (const [timestamp, latency] of latencyHisRes) { for (const [timestamp, latency] of reply) {
assert.equal(typeof timestamp, 'number'); assert.equal(typeof timestamp, 'number');
assert.equal(typeof latency, 'number'); assert.equal(typeof latency, 'number');
} }
}, GLOBAL.SERVERS.OPEN); }, GLOBAL.SERVERS.OPEN);
}); });

View File

@@ -1,27 +1,33 @@
export type EventType = ( import { ArrayReply, TuplesReply, NumberReply, Command } from '../RESP/types';
'active-defrag-cycle' |
'aof-fsync-always' | export type LatencyEventType = (
'aof-stat' | 'active-defrag-cycle' |
'aof-rewrite-diff-write' | 'aof-fsync-always' |
'aof-rename' | 'aof-stat' |
'aof-write' | 'aof-rewrite-diff-write' |
'aof-write-active-child' | 'aof-rename' |
'aof-write-alone' | 'aof-write' |
'aof-write-pending-fsync' | 'aof-write-active-child' |
'command' | 'aof-write-alone' |
'expire-cycle' | 'aof-write-pending-fsync' |
'eviction-cycle' | 'command' |
'eviction-del' | 'expire-cycle' |
'fast-command' | 'eviction-cycle' |
'fork' | 'eviction-del' |
'rdb-unlink-temp-file' 'fast-command' |
'fork' |
'rdb-unlink-temp-file'
); );
export function transformArguments(event: EventType) { export default {
FIRST_KEY_INDEX: undefined,
IS_READ_ONLY: true,
transformArguments(event: LatencyEventType) {
return ['LATENCY', 'HISTORY', event]; return ['LATENCY', 'HISTORY', event];
} },
transformReply: undefined as unknown as () => ArrayReply<TuplesReply<[
timestamp: NumberReply,
latency: NumberReply
]>>
} as const satisfies Command;
export declare function transformReply(): Array<[
timestamp: number,
latency: number,
]>;

View File

@@ -11,13 +11,13 @@ describe('LATENCY LATEST', () => {
}); });
testUtils.testWithClient('client.latencyLatest', async client => { testUtils.testWithClient('client.latencyLatest', async client => {
await Promise.all([ const [,, reply] = await Promise.all([
client.configSet('latency-monitor-threshold', '100'), client.configSet('latency-monitor-threshold', '100'),
client.sendCommand(['DEBUG', 'SLEEP', '1']) client.sendCommand(['DEBUG', 'SLEEP', '1']),
client.latencyLatest()
]); ]);
const latency = await client.latencyLatest(); assert.ok(Array.isArray(reply));
assert.ok(Array.isArray(latency)); for (const [name, timestamp, latestLatency, allTimeLatency] of reply) {
for (const [name, timestamp, latestLatency, allTimeLatency] of latency) {
assert.equal(typeof name, 'string'); assert.equal(typeof name, 'string');
assert.equal(typeof timestamp, 'number'); assert.equal(typeof timestamp, 'number');
assert.equal(typeof latestLatency, 'number'); assert.equal(typeof latestLatency, 'number');

View File

@@ -1,48 +1,48 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './PUBSUB_SHARDNUMSUB'; import PUBSUB_SHARDNUMSUB from './PUBSUB_SHARDNUMSUB';
describe('PUBSUB SHARDNUMSUB', () => { describe('PUBSUB SHARDNUMSUB', () => {
testUtils.isVersionGreaterThanHook([7]); testUtils.isVersionGreaterThanHook([7]);
describe('transformArguments', () => { describe('transformArguments', () => {
it('simple', () => { it('simple', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(), PUBSUB_SHARDNUMSUB.transformArguments(),
['PUBSUB', 'SHARDNUMSUB'] ['PUBSUB', 'SHARDNUMSUB']
); );
});
it('string', () => {
assert.deepEqual(
transformArguments('channel'),
['PUBSUB', 'SHARDNUMSUB', 'channel']
);
});
it('array', () => {
assert.deepEqual(
transformArguments(['1', '2']),
['PUBSUB', 'SHARDNUMSUB', '1', '2']
);
});
}); });
testUtils.testWithClient('client.pubSubShardNumSub', async client => { it('string', () => {
assert.deepEqual( assert.deepEqual(
await client.pubSubShardNumSub(['foo', 'bar']), PUBSUB_SHARDNUMSUB.transformArguments('channel'),
Object.create(null, { ['PUBSUB', 'SHARDNUMSUB', 'channel']
foo: { );
value: 0, });
configurable: true,
enumerable: true it('array', () => {
}, assert.deepEqual(
bar: { PUBSUB_SHARDNUMSUB.transformArguments(['1', '2']),
value: 0, ['PUBSUB', 'SHARDNUMSUB', '1', '2']
configurable: true, );
enumerable: true });
} });
})
); testUtils.testWithClient('client.pubSubShardNumSub', async client => {
}, GLOBAL.SERVERS.OPEN); assert.deepEqual(
await client.pubSubShardNumSub(['foo', 'bar']),
Object.create(null, {
foo: {
value: 0,
configurable: true,
enumerable: true
},
bar: {
value: 0,
configurable: true,
enumerable: true
}
})
);
}, GLOBAL.SERVERS.OPEN);
}); });

View File

@@ -1,24 +1,24 @@
import { pushVerdictArguments } from './generic-transformers'; import { ArrayReply, BlobStringReply, NumberReply, UnwrapReply, Command } from '../RESP/types';
import { RedisCommandArgument, RedisCommandArguments } from '.'; import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
export const IS_READ_ONLY = true; export default {
FIRST_KEY_INDEX: undefined,
export function transformArguments( IS_READ_ONLY: true,
channels?: Array<RedisCommandArgument> | RedisCommandArgument transformArguments(channels?: RedisVariadicArgument) {
): RedisCommandArguments {
const args = ['PUBSUB', 'SHARDNUMSUB']; const args = ['PUBSUB', 'SHARDNUMSUB'];
if (channels) return pushVerdictArguments(args, channels); if (channels) return pushVariadicArguments(args, channels);
return args; return args;
} },
transformReply(reply: UnwrapReply<ArrayReply<BlobStringReply | NumberReply>>) {
const transformedReply: Record<string, NumberReply> = Object.create(null);
export function transformReply(rawReply: Array<string | number>): Record<string, number> { for (let i = 0; i < reply.length; i += 2) {
const transformedReply = Object.create(null); transformedReply[(reply[i] as BlobStringReply).toString()] = reply[i + 1] as NumberReply;
for (let i = 0; i < rawReply.length; i += 2) {
transformedReply[rawReply[i]] = rawReply[i + 1];
} }
return transformedReply; return transformedReply;
} }
} as const satisfies Command;

View File

@@ -1,74 +1,84 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './RESTORE'; import RESTORE from './RESTORE';
import { RESP_TYPES } from '../RESP/decoder';
describe('RESTORE', () => { describe('RESTORE', () => {
describe('transformArguments', () => { describe('transformArguments', () => {
it('simple', () => { it('simple', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('key', 0, 'value'), RESTORE.transformArguments('key', 0, 'value'),
['RESTORE', 'key', '0', 'value'] ['RESTORE', 'key', '0', 'value']
); );
});
it('with REPLACE', () => {
assert.deepEqual(
transformArguments('key', 0, 'value', {
REPLACE: true
}),
['RESTORE', 'key', '0', 'value', 'REPLACE']
);
});
it('with ABSTTL', () => {
assert.deepEqual(
transformArguments('key', 0, 'value', {
ABSTTL: true
}),
['RESTORE', 'key', '0', 'value', 'ABSTTL']
);
});
it('with IDLETIME', () => {
assert.deepEqual(
transformArguments('key', 0, 'value', {
IDLETIME: 1
}),
['RESTORE', 'key', '0', 'value', 'IDLETIME', '1']
);
});
it('with FREQ', () => {
assert.deepEqual(
transformArguments('key', 0, 'value', {
FREQ: 1
}),
['RESTORE', 'key', '0', 'value', 'FREQ', '1']
);
});
it('with REPLACE, ABSTTL, IDLETIME and FREQ', () => {
assert.deepEqual(
transformArguments('key', 0, 'value', {
REPLACE: true,
ABSTTL: true,
IDLETIME: 1,
FREQ: 2
}),
['RESTORE', 'key', '0', 'value', 'REPLACE', 'ABSTTL', 'IDLETIME', '1', 'FREQ', '2']
);
});
}); });
testUtils.testWithClient('client.restore', async client => { it('with REPLACE', () => {
const [, dump] = await Promise.all([ assert.deepEqual(
client.set('source', 'value'), RESTORE.transformArguments('key', 0, 'value', {
client.dump(client.commandOptions({ returnBuffers: true }), 'source') REPLACE: true
]); }),
['RESTORE', 'key', '0', 'value', 'REPLACE']
);
});
assert.equal( it('with ABSTTL', () => {
await client.restore('destination', 0, dump), assert.deepEqual(
'OK' RESTORE.transformArguments('key', 0, 'value', {
); ABSTTL: true
}, GLOBAL.SERVERS.OPEN); }),
['RESTORE', 'key', '0', 'value', 'ABSTTL']
);
});
it('with IDLETIME', () => {
assert.deepEqual(
RESTORE.transformArguments('key', 0, 'value', {
IDLETIME: 1
}),
['RESTORE', 'key', '0', 'value', 'IDLETIME', '1']
);
});
it('with FREQ', () => {
assert.deepEqual(
RESTORE.transformArguments('key', 0, 'value', {
FREQ: 1
}),
['RESTORE', 'key', '0', 'value', 'FREQ', '1']
);
});
it('with REPLACE, ABSTTL, IDLETIME and FREQ', () => {
assert.deepEqual(
RESTORE.transformArguments('key', 0, 'value', {
REPLACE: true,
ABSTTL: true,
IDLETIME: 1,
FREQ: 2
}),
['RESTORE', 'key', '0', 'value', 'REPLACE', 'ABSTTL', 'IDLETIME', '1', 'FREQ', '2']
);
});
});
testUtils.testWithClient('client.restore', async client => {
const [, dump] = await Promise.all([
client.set('source', 'value'),
client.dump('source')
]);
assert.equal(
await client.restore('destination', 0, dump),
'OK'
);
}, {
...GLOBAL.SERVERS.OPEN,
clientOptions: {
commandOptions: {
typeMapping: {
[RESP_TYPES.BLOB_STRING]: Buffer
}
}
}
});
}); });

View File

@@ -1,39 +1,40 @@
import { RedisCommandArgument, RedisCommandArguments } from '.'; import { RedisArgument, SimpleStringReply, Command } from '../RESP/types';
export const FIRST_KEY_INDEX = 1; export interface RestoreOptions {
REPLACE?: boolean;
interface RestoreOptions { ABSTTL?: boolean;
REPLACE?: true; IDLETIME?: number;
ABSTTL?: true; FREQ?: number;
IDLETIME?: number;
FREQ?: number;
} }
export function transformArguments( export default {
key: RedisCommandArgument, FIRST_KEY_INDEX: 1,
IS_READ_ONLY: false,
transformArguments(
key: RedisArgument,
ttl: number, ttl: number,
serializedValue: RedisCommandArgument, serializedValue: RedisArgument,
options?: RestoreOptions options?: RestoreOptions
): RedisCommandArguments { ) {
const args = ['RESTORE', key, ttl.toString(), serializedValue]; const args = ['RESTORE', key, ttl.toString(), serializedValue];
if (options?.REPLACE) { if (options?.REPLACE) {
args.push('REPLACE'); args.push('REPLACE');
} }
if (options?.ABSTTL) { if (options?.ABSTTL) {
args.push('ABSTTL'); args.push('ABSTTL');
} }
if (options?.IDLETIME) { if (options?.IDLETIME) {
args.push('IDLETIME', options.IDLETIME.toString()); args.push('IDLETIME', options.IDLETIME.toString());
} }
if (options?.FREQ) { if (options?.FREQ) {
args.push('FREQ', options.FREQ.toString()); args.push('FREQ', options.FREQ.toString());
} }
return args; return args;
} },
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
export declare function transformReply(): 'OK'; } as const satisfies Command;

View File

@@ -38,6 +38,7 @@ import CLIENT_INFO from './CLIENT_INFO';
import CLIENT_KILL from './CLIENT_KILL'; import CLIENT_KILL from './CLIENT_KILL';
import CLIENT_LIST from './CLIENT_LIST'; import CLIENT_LIST from './CLIENT_LIST';
import CLIENT_NO_EVICT from './CLIENT_NO-EVICT'; import CLIENT_NO_EVICT from './CLIENT_NO-EVICT';
import CLIENT_NO_TOUCH from './CLIENT_NO-TOUCH';
import CLIENT_PAUSE from './CLIENT_PAUSE'; import CLIENT_PAUSE from './CLIENT_PAUSE';
import CLIENT_SETNAME from './CLIENT_SETNAME'; import CLIENT_SETNAME from './CLIENT_SETNAME';
import CLIENT_TRACKING from './CLIENT_TRACKING'; import CLIENT_TRACKING from './CLIENT_TRACKING';
@@ -59,6 +60,7 @@ import CLUSTER_KEYSLOT from './CLUSTER_KEYSLOT';
import CLUSTER_LINKS from './CLUSTER_LINKS'; import CLUSTER_LINKS from './CLUSTER_LINKS';
import CLUSTER_MEET from './CLUSTER_MEET'; import CLUSTER_MEET from './CLUSTER_MEET';
import CLUSTER_MYID from './CLUSTER_MYID'; import CLUSTER_MYID from './CLUSTER_MYID';
import CLUSTER_MYSHARDID from './CLUSTER_MYSHARDID';
import CLUSTER_NODES from './CLUSTER_NODES'; import CLUSTER_NODES from './CLUSTER_NODES';
import CLUSTER_REPLICAS from './CLUSTER_REPLICAS'; import CLUSTER_REPLICAS from './CLUSTER_REPLICAS';
import CLUSTER_REPLICATE from './CLUSTER_REPLICATE'; import CLUSTER_REPLICATE from './CLUSTER_REPLICATE';
@@ -154,6 +156,7 @@ import KEYS from './KEYS';
import LASTSAVE from './LASTSAVE'; import LASTSAVE from './LASTSAVE';
import LATENCY_DOCTOR from './LATENCY_DOCTOR'; import LATENCY_DOCTOR from './LATENCY_DOCTOR';
import LATENCY_GRAPH from './LATENCY_GRAPH'; import LATENCY_GRAPH from './LATENCY_GRAPH';
import LATENCY_HISTORY from './LATENCY_HISTORY';
import LATENCY_LATEST from './LATENCY_LATEST'; import LATENCY_LATEST from './LATENCY_LATEST';
import LCS_IDX_WITHMATCHLEN from './LCS_IDX_WITHMATCHLEN'; import LCS_IDX_WITHMATCHLEN from './LCS_IDX_WITHMATCHLEN';
import LCS_IDX from './LCS_IDX'; import LCS_IDX from './LCS_IDX';
@@ -205,11 +208,15 @@ import PUBLISH from './PUBLISH';
import PUBSUB_CHANNELS from './PUBSUB_CHANNELS'; import PUBSUB_CHANNELS from './PUBSUB_CHANNELS';
import PUBSUB_NUMPAT from './PUBSUB_NUMPAT'; import PUBSUB_NUMPAT from './PUBSUB_NUMPAT';
import PUBSUB_NUMSUB from './PUBSUB_NUMSUB'; import PUBSUB_NUMSUB from './PUBSUB_NUMSUB';
import PUBSUB_SHARDNUMSUB from './PUBSUB_SHARDNUMSUB';
import PUBSUB_SHARDCHANNELS from './PUBSUB_SHARDCHANNELS'; import PUBSUB_SHARDCHANNELS from './PUBSUB_SHARDCHANNELS';
import RANDOMKEY from './RANDOMKEY'; import RANDOMKEY from './RANDOMKEY';
import READONLY from './READONLY'; import READONLY from './READONLY';
import RENAME from './RENAME'; import RENAME from './RENAME';
import RENAMENX from './RENAMENX'; import RENAMENX from './RENAMENX';
import REPLICAOF from './REPLICAOF';
import RESTORE_ASKING from './RESTORE-ASKING';
import RESTORE from './RESTORE';
import ROLE from './ROLE'; import ROLE from './ROLE';
import RPOP_COUNT from './RPOP_COUNT'; import RPOP_COUNT from './RPOP_COUNT';
import RPOP from './RPOP'; import RPOP from './RPOP';
@@ -405,6 +412,8 @@ export default {
clientList: CLIENT_LIST, clientList: CLIENT_LIST,
'CLIENT_NO-EVICT': CLIENT_NO_EVICT, 'CLIENT_NO-EVICT': CLIENT_NO_EVICT,
clientNoEvict: CLIENT_NO_EVICT, clientNoEvict: CLIENT_NO_EVICT,
'CLIENT_NO-TOUCH': CLIENT_NO_TOUCH,
clientNoTouch: CLIENT_NO_TOUCH,
CLIENT_PAUSE, CLIENT_PAUSE,
clientPause: CLIENT_PAUSE, clientPause: CLIENT_PAUSE,
CLIENT_SETNAME, CLIENT_SETNAME,
@@ -447,6 +456,8 @@ export default {
clusterMeet: CLUSTER_MEET, clusterMeet: CLUSTER_MEET,
CLUSTER_MYID, CLUSTER_MYID,
clusterMyId: CLUSTER_MYID, clusterMyId: CLUSTER_MYID,
CLUSTER_MYSHARDID,
clusterMyShardId: CLUSTER_MYSHARDID,
CLUSTER_NODES, CLUSTER_NODES,
clusterNodes: CLUSTER_NODES, clusterNodes: CLUSTER_NODES,
CLUSTER_REPLICAS, CLUSTER_REPLICAS,
@@ -637,6 +648,8 @@ export default {
latencyDoctor: LATENCY_DOCTOR, latencyDoctor: LATENCY_DOCTOR,
LATENCY_GRAPH, LATENCY_GRAPH,
latencyGraph: LATENCY_GRAPH, latencyGraph: LATENCY_GRAPH,
LATENCY_HISTORY,
latencyHistory: LATENCY_HISTORY,
LATENCY_LATEST, LATENCY_LATEST,
latencyLatest: LATENCY_LATEST, latencyLatest: LATENCY_LATEST,
LCS_IDX_WITHMATCHLEN, LCS_IDX_WITHMATCHLEN,
@@ -741,6 +754,8 @@ export default {
pubSubNumPat: PUBSUB_NUMPAT, pubSubNumPat: PUBSUB_NUMPAT,
PUBSUB_NUMSUB, PUBSUB_NUMSUB,
pubSubNumSub: PUBSUB_NUMSUB, pubSubNumSub: PUBSUB_NUMSUB,
PUBSUB_SHARDNUMSUB,
pubSubShardNumSub: PUBSUB_SHARDNUMSUB,
PUBSUB_SHARDCHANNELS, PUBSUB_SHARDCHANNELS,
pubSubShardChannels: PUBSUB_SHARDCHANNELS, pubSubShardChannels: PUBSUB_SHARDCHANNELS,
RANDOMKEY, RANDOMKEY,
@@ -751,6 +766,12 @@ export default {
rename: RENAME, rename: RENAME,
RENAMENX, RENAMENX,
renameNX: RENAMENX, renameNX: RENAMENX,
REPLICAOF,
replicaOf: REPLICAOF,
'RESTORE-ASKING': RESTORE_ASKING,
restoreAsking: RESTORE_ASKING,
RESTORE,
restore: RESTORE,
RPOP_COUNT, RPOP_COUNT,
rPopCount: RPOP_COUNT, rPopCount: RPOP_COUNT,
ROLE, ROLE,

View File

@@ -34,11 +34,9 @@ Looking for a high-level library to handle object mapping? See [redis-om-node](h
```javascript ```javascript
import { createClient } from 'redis'; import { createClient } from 'redis';
const client = createClient(); const client = await createClient()
.on('error', err => console.log('Redis Client Error', err))
client.on('error', err => console.log('Redis Client Error', err)); .connect();
await client.connect();
await client.set('key', 'value'); await client.set('key', 'value');
const value = await client.get('key'); const value = await client.get('key');