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

True timeouts for cache calls #22

Merged
merged 1 commit into from
Jan 27, 2016
Merged

True timeouts for cache calls #22

merged 1 commit into from
Jan 27, 2016

Conversation

jkrems
Copy link
Contributor

@jkrems jkrems commented Jan 26, 2016

There are a couple of potential improvements that I didn't include in here, such as:

  • A gofer-like globalDefaults setting that applies to all caches
  • A gofer-like default timeout so cache calls never have no timeout at all

The latter would be a breaking change, so I kept it to the bare minimum.

@@ -98,8 +98,16 @@ Cache.prototype.set = function set(rawKey, val, _opts, _cb) {
return this._set(key, val, optsWithDefaults).nodeify(args.cb);
};

Cache.prototype._applyTimeout = function _applyTimeout(value) {
var timeoutMs = this.defaults.timeout;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timeout should be added to the README where you mention Cache.setDefaults(defaults)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Added to the docs, stressing how important it is.

@ageitgey
Copy link

LGTM.

Adding timeout logic like this always makes me nervous that it will work fine in simple test cases but behavior weirdly under high load/concurrency. But I guess the only way to verify that is to test it under high load :)

@jkrems
Copy link
Contributor Author

jkrems commented Jan 27, 2016

Yeah, I have similar concerns. But I think because the actual sockets aren't opened per command but via a central pool, letting them "hang" shouldn't lead to resource exhaustion. Hopefully. ^^

jkrems added a commit that referenced this pull request Jan 27, 2016
True timeouts for cache calls
@jkrems jkrems merged commit 3f2b4b0 into master Jan 27, 2016
@jkrems jkrems deleted the jk-timeout branch January 27, 2016 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants