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

chore: add callback functionality back in

This also improves the performance for multi / batch commands a lot.
The reason is that now there are only callbacks internally even if
a promise is going to be returned in the end.
This commit is contained in:
Ruben Bridgewater
2017-11-29 19:16:40 -02:00
parent 2b4ab10305
commit d7c31da598
10 changed files with 288 additions and 184 deletions

View File

@@ -1,6 +1,5 @@
'use strict'
const Command = require('./command')
const debug = require('./debug')
const utils = require('./utils')
@@ -52,8 +51,8 @@ function readyHandler(client) {
client.ready = true
if (client.selectedDb !== undefined) {
client.internalSendCommand(new Command('select', [client.selectedDb])).catch((err) => {
if (!client._closing) {
client.select(client.selectedDb, (err) => {
if (err !== null && !client._closing) {
// TODO: These internal things should be wrapped in a
// special error that describes what is happening
process.nextTick(client.emit, 'error', err)
@@ -61,8 +60,8 @@ function readyHandler(client) {
})
}
if (client._monitoring) { // Monitor has to be fired before pub sub commands
client.internalSendCommand(new Command('monitor', [])).catch((err) => {
if (!client._closing) {
client.monitor((err) => {
if (err !== null && !client._closing) {
process.nextTick(client.emit, 'error', err)
}
})