【发布时间】:2022-12-19 20:42:51
【问题描述】:
我正在尝试使用 redis-lock (https://www.npmjs.com/package/redis-lock) 但它抛出错误请让我知道这里出了什么问题
test();
async function test()
{
const client = require('redis').createClient();
const { promisify } = require('util');
const lock = promisify(require('redis-lock')(client));
client.on('connect', function(){
console.log('Connected to Redis');
});
client.on('error', function(err) {
console.log('Redis error: ' + err);
});
const unlock = await lock('lockString');
// Perform your task;
unlock();
}
错误
(节点:22972)UnhandledPromiseRejectionWarning:错误:您必须指定http://github.com/mranney/node_redis的客户端实例 在 module.exports (E:\XPA-GS(replacement)\Test\node_modules\redis-lock\index.js:23:9) 在 Test\test-redis-lock.js:46:59 在步骤 (Test\test-redis-lock.js:32:23) 在 Object.next (Test\test-redis-lock.js:13:53) 在 Test\test-redis-lock.js:7:71 在新的承诺 () 在 __awaiter (Test\test-redis-lock.js:3:12) 在测试中(测试 \test-redis-lock.js:39:12) 在对象。 (测试\test-redis-lock.js:37:1) 在 Module._compile (internal/modules/cjs/loader.js:1085:14)
【问题讨论】:
标签: node.js typescript redis node-redis