-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cluster): autopipeline when keyPrefix is used
Previously the building of pipelines ignored the key prefix. It was possible that two keys, foo and bar, might be set into the same pipeline. However, after being prefixed by a configured "keyPrefix" value, they may no longer belong to the same pipeline. This led to the error: "All keys in the pipeline should belong to the same slots allocation group" Amended version of https://github.com/luin/ioredis/pull/1335/files - see comments on that PR This may fix #1264 and #1248.
- Loading branch information
1 parent
beefcc1
commit e1cab95
Showing
6 changed files
with
142 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import defaults = require("lodash.defaults"); | ||
import flatten = require("lodash.flatten"); | ||
import isArguments = require("lodash.isarguments"); | ||
|
||
export function noop() {} | ||
|
||
export { defaults, flatten }; | ||
export { defaults, flatten, isArguments }; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { expect } from "chai"; | ||
import { getFirstValueInFlattenedArray } from "../../lib/autoPipelining"; | ||
import { flatten } from "../../lib/utils/lodash"; | ||
|
||
describe("autoPipelining", function () { | ||
const expectGetFirstValueIs = (values, expected) => { | ||
expect(getFirstValueInFlattenedArray(values)).to.eql(expected); | ||
// getFirstValueInFlattenedArray should behave the same way as flatten(args)[0] | ||
// but be much more efficient. | ||
expect(flatten(values)[0]).to.eql(expected); | ||
}; | ||
|
||
it("should be able to efficiently get array args", function () { | ||
expectGetFirstValueIs([], undefined); | ||
expectGetFirstValueIs([null, "key"], null); | ||
expectGetFirstValueIs(["key", "value"], "key"); | ||
expectGetFirstValueIs([[], "key"], "key"); | ||
expectGetFirstValueIs([["key"]], "key"); | ||
// @ts-ignore | ||
expectGetFirstValueIs([[["key"]]], ["key"]); | ||
// @ts-ignore | ||
expectGetFirstValueIs([0, 1, 2, 3, 4], 0); | ||
// @ts-ignore | ||
expectGetFirstValueIs([[true]], true); | ||
// @ts-ignore | ||
expectGetFirstValueIs([Buffer.from("test")], Buffer.from("test")); | ||
// @ts-ignore | ||
expectGetFirstValueIs([{}], {}); | ||
// lodash.isArguments is true for this legacy js way to get argument lists | ||
const createArguments = function () { | ||
return arguments; | ||
}; | ||
// @ts-ignore | ||
expectGetFirstValueIs([createArguments(), createArguments("key")], "key"); | ||
// @ts-ignore | ||
expectGetFirstValueIs([createArguments("")], ""); | ||
}); | ||
}); |