Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

feat: drop node4 support #39

Merged
merged 2 commits into from
Sep 15, 2018
Merged

feat: drop node4 support #39

merged 2 commits into from
Sep 15, 2018

Conversation

aaarichter
Copy link

@aaarichter aaarichter commented Sep 8, 2018

Changes:

  • drop node4 support
  • use Map API instead of object hash maps
  • remove lodash dependency

return cached;
};

cached.knownCaches = function knownCaches() {
return Object.keys(namedCaches);
return [...namedCaches.keys()];
Copy link
Author

Choose a reason for hiding this comment

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

Q: should we return a MapIterator instead ?

Copy link
Contributor

Choose a reason for hiding this comment

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

We wanted to keep the interface slim. Exposing a map iterator would lock us into using a Map internally in future versions as well. I think using an array here is great (a Set would also work but might be unnecessary overhead).

@aaarichter
Copy link
Author

aaarichter commented Sep 9, 2018

@jkrems regarding the idea on "not waiting for the cache writing promise", do you think https://gist.github.com/aaarichter/22cbcdf636536d542d7e0e10c0d75064 would do?

Copy link
Contributor

@jkrems jkrems left a comment

Choose a reason for hiding this comment

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

Very nice! Thanks for working on this. I left a few minor comments. Also, I think it would be fair to drop "breaking change". We have treated dropping unsupported node versions as "usual maintenance" in the past. Nobody should be running those in production anyhow.

let loadingNewValue = cache.staleOrPending[key] !== undefined;

if ((!hit || expired) && !loadingNewValue) {
if (
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason why we went back to a huge if condition here?

Copy link
Author

Choose a reason for hiding this comment

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

so the reason for the change is the likelihood of each part on the condition as well as calling functions / getting values

  • cache.staleOrPending is set -> skip the more complex condition && (hit || expired)
  • hit: if no hit then expired does not need to be calculated
  • util.isExpired(wrappedValue && wrappedValue.b) don't check the value if any of the other cheaper checks pass

return cached;
};

cached.knownCaches = function knownCaches() {
return Object.keys(namedCaches);
return [...namedCaches.keys()];
Copy link
Contributor

Choose a reason for hiding this comment

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

We wanted to keep the interface slim. Exposing a map iterator would lock us into using a Map internally in future versions as well. I think using an array here is great (a Set would also work but might be unnecessary overhead).

Andreas Richter added 2 commits September 13, 2018 20:18
Changes:
- [x] drop node4 support
- [x] use Map API instead of object hash maps
- [x] remove lodash dependency
@aaarichter
Copy link
Author

aaarichter commented Sep 14, 2018

update the commit messages and addressed (hopefully) the feedback for the noop and constant function

const Memcached = require('memcached');

const noop = () => undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

Side note: Using function would have been shorter and wouldn't have closed over the weird module-scope this.

function noop() {}
const noop = () => undefined;

const getName = util.deprecate(function getName(name) {
return name || 'default';
}, 'Unnamed caches and caches with non-string names are deprecated.');
const getName = util.deprecate(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: This turns a previously named function into something that won't have a meaningful .name anymore which is a little worse in terms of debugging.

@@ -1,6 +1,6 @@
import assert from 'assertive';
import Bluebird from 'bluebird';
Copy link
Contributor

Choose a reason for hiding this comment

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

Huh, we should undo this eventually. Completely forgot that we were using babel script modules in this project. Good reminder. :)

@jkrems jkrems merged commit adb17d0 into groupon:master Sep 15, 2018
@aaarichter aaarichter deleted the delay-writing branch September 15, 2018 16:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants