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

chore: upgrade ioredis to v5 #231

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@
]
},
"devDependencies": {
"@types/ioredis": "^4.28.8",
"@types/node": "^17.0.21",
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.13.0",
"ava": "^4.1.0",
"eslint": "^8.10.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"ioredis": "^4.28.5",
"ioredis": "^5.2.3",
"nodemon": "^2.0.15",
"prettier": "^2.5.1",
"typescript": "~4.6.2"
Expand Down
17 changes: 10 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,11 +558,12 @@ export default class Redlock extends EventEmitter {
let result: number;
try {
// Attempt to evaluate the script by its hash.
const shaResult = (await client.evalsha(script.hash, keys.length, [
const shaResult = await client.evalsha(
script.hash,
keys.length,
...keys,
...args,
])) as unknown;

...args
);
if (typeof shaResult !== "number") {
throw new Error(
`Unexpected result of type ${typeof shaResult} returned from redis.`
Expand All @@ -579,10 +580,12 @@ export default class Redlock extends EventEmitter {
) {
throw error;
}
const rawResult = (await client.eval(script.value, keys.length, [
const rawResult = await client.eval(
script.value,
keys.length,
...keys,
...args,
])) as unknown;
...args
);

if (typeof rawResult !== "number") {
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion src/multi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ${(await Promise.all(error.attempts))
async function waitForCluster(redis: Cluster): Promise<void> {
async function checkIsReady(): Promise<boolean> {
return (
((await redis.cluster("info")) as string).match(
((await redis.cluster("INFO")) as string).match(
/^cluster_state:(.+)$/m
)?.[1] === "ok"
);
Expand Down
2 changes: 1 addition & 1 deletion src/single.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ${(await Promise.all(error.attempts))
async function waitForCluster(redis: Cluster): Promise<void> {
async function checkIsReady(): Promise<boolean> {
return (
((await redis.cluster("info")) as string).match(
((await redis.cluster("INFO")) as string).match(
/^cluster_state:(.+)$/m
)?.[1] === "ok"
);
Expand Down