Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add memcached.enabled (for issue #291) #292

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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