Skip to content

Commit

Permalink
chore: upgrade ioredis to v5
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikamura committed Jan 30, 2023
1 parent dc7bcd9 commit 7b1b9c4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,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
11 changes: 2 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,7 @@ 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, [
...keys,
...args,
])) as unknown;

const shaResult = await client.evalsha(script.hash, keys.length, ...keys, ...args);
if (typeof shaResult !== "number") {
throw new Error(
`Unexpected result of type ${typeof shaResult} returned from redis.`
Expand All @@ -573,10 +569,7 @@ export default class Redlock extends EventEmitter {
) {
throw error;
}
const rawResult = (await client.eval(script.value, keys.length, [
...keys,
...args,
])) as unknown;
const rawResult = await client.eval(script.value, keys.length, ...keys, ...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

0 comments on commit 7b1b9c4

Please sign in to comment.