mirror of
https://github.com/lingble/safe-redis-leader.git
synced 2025-10-28 11:12:36 +00:00
feat(*): bump ioredis version
This commit is contained in:
6585
package-lock.json
generated
6585
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -27,10 +27,9 @@
|
||||
},
|
||||
"homepage": "https://github.com/Nesci28/safe-redis-leader/blob/master/README.md",
|
||||
"dependencies": {
|
||||
"ioredis": "^4.27.6"
|
||||
"ioredis": "^5.2.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/ioredis": "^4.26.5",
|
||||
"@types/jest": "^26.0.24",
|
||||
"@types/lodash": "^4.14.171",
|
||||
"@types/node": "^16.3.2",
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { readFile as fsReadFile } from "fs";
|
||||
import IORedis from "ioredis";
|
||||
import Redis, { RedisKey } from "ioredis";
|
||||
import { promisify } from "util";
|
||||
|
||||
const readFile = promisify(fsReadFile);
|
||||
|
||||
type getIsEqualDeleteType = {
|
||||
getIsEqualDelete?: (key: IORedis.KeyType, id: string) => Promise<boolean>;
|
||||
getIsEqualDelete?: (key: RedisKey, id: string) => Promise<boolean>;
|
||||
};
|
||||
|
||||
export async function atomicGetIsEqualDelete(
|
||||
asyncRedis: IORedis.Redis & getIsEqualDeleteType,
|
||||
key: IORedis.KeyType,
|
||||
asyncRedis: Redis & getIsEqualDeleteType,
|
||||
key: RedisKey,
|
||||
id: string,
|
||||
): Promise<boolean> {
|
||||
if (!asyncRedis.getIsEqualDelete) {
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { readFile as fsReadFile } from "fs";
|
||||
import IORedis from "ioredis";
|
||||
import Redis, { RedisKey } from "ioredis";
|
||||
import { promisify } from "util";
|
||||
|
||||
const readFile = promisify(fsReadFile);
|
||||
|
||||
type getIsEqualSetPExpireType = {
|
||||
getIsEqualSetPExpire?: (key: IORedis.KeyType, id: string, ms: number) => Promise<boolean>;
|
||||
getIsEqualSetPExpire?: (key: RedisKey, id: string, ms: number) => Promise<boolean>;
|
||||
};
|
||||
|
||||
export async function atomicGetIsEqualSetPExpire(
|
||||
asyncRedis: IORedis.Redis & getIsEqualSetPExpireType,
|
||||
key: IORedis.KeyType,
|
||||
asyncRedis: Redis & getIsEqualSetPExpireType,
|
||||
key: RedisKey,
|
||||
id: string,
|
||||
ms: number,
|
||||
): Promise<boolean> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { BinaryLike, createHash, randomBytes } from "crypto";
|
||||
import IORedis from "ioredis";
|
||||
import Redis, { RedisKey } from "ioredis";
|
||||
|
||||
import { atomicGetIsEqualDelete } from "./atomicGetIsEqualDelete";
|
||||
import { atomicGetIsEqualSetPExpire } from "./atomicGetIsEqualSetPExpire";
|
||||
@@ -31,19 +31,19 @@ export class SafeRedisLeader {
|
||||
|
||||
public electTimeoutId!: ReturnType<typeof setTimeout>;
|
||||
|
||||
public asyncRedis: IORedis.Redis;
|
||||
public asyncRedis: Redis;
|
||||
|
||||
public ttl: number;
|
||||
|
||||
public wait: number;
|
||||
|
||||
public key: IORedis.KeyType;
|
||||
public key: RedisKey;
|
||||
|
||||
constructor(
|
||||
asyncRedis: IORedis.Redis,
|
||||
asyncRedis: Redis,
|
||||
ttl: number,
|
||||
wait: number,
|
||||
key: IORedis.KeyType,
|
||||
key: RedisKey,
|
||||
) {
|
||||
this.asyncRedis = asyncRedis;
|
||||
this.ttl = ttl;
|
||||
|
||||
Reference in New Issue
Block a user