Skip to content

Conversation

@danikaze
Copy link

@danikaze danikaze commented Dec 17, 2016

Implements a new option (enabled) for issue #291
By default to true, it doesn't change the current behavior. If set to false, bypass the memcached calls, invoking the error callback with ENOTENABLED value.
This allows to test the same code with/without usage of memcached.

It also allows to manage errors in case of server failure to avoid waiting for a callback that won't come.

The usage is as easy as:

var memcached = new Memcached(server, { enabled: false });

or in real time:

memcached.on('issue', function() {
    memcached.enabled = false;
}
memcached.on('reconnect', function() {
    memcached.enabled = true;
}
memcached.get('key', function(error, data) {
    // now if the server is down this function should be called with error ENOTENABLED instead of hanging
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant