node-redlock icon indicating copy to clipboard operation
node-redlock copied to clipboard

TypeError: client.evalsha is not a function

Open epubreader opened this issue 1 year ago • 3 comments

did not support node-redis, const redis = require("redis");

TypeError: client.evalsha is not a function at Redlock._attemptOperationOnClient (/home/mason/project/epubpub/epub-search/node_modules/redlock/dist/cjs/index.js:362:49) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

const redisClient = require("./redisClient"); const { default: Redlock, ResourceLockedError } = require("redlock");

const redLock = new Redlock([redisClient], { // the expected clock drift; for more details // see http://redis.io/topics/distlock driftFactor: 0.01, // time in ms

// the max number of times Redlock will attempt // to lock a resource before erroring retryCount: 4,

// the time in ms between attempts retryDelay: 50, // time in ms

// the max time in ms randomly added to retries // to improve performance under high contention // see https://www.awsarchitectureblog.com/2015/03/backoff.html retryJitter: 25, // time in ms });

redLock.on("error", (error) => { // Ignore cases where a resource is explicitly marked as locked on a client. if (error instanceof ResourceLockedError) { return; }

// Log all other errors. console.error(error); });

module.exports = redLock;

const config = require("../config");

const redis = require("redis"); const redisPort = config.redis.port; const redisHost = config.redis.host; const redisPass = config.redis.password;

let redisConfig = { socket: { host: redisHost, port: redisPort, }, password: redisPass, };

const redisClient = redis.createClient(redisConfig);

redisClient.on("error", (err) => { console.error("Error: %o ", err); });

redisClient.on("connect", () => { console.log("Connected to Redis"); });

redisClient.on("close", () => { console.log("Connection to redis has closed"); });

redisClient.connect();

module.exports = redisClient;

epubreader avatar Nov 06 '23 09:11 epubreader