Redis,'set' 命令 node.js 的参数数量错误

Redis, wrong number of arguments for 'set' command node.js

我是最简单的使用Redis存储session的nodejs应用。我已经在 windows 上下载并启动了 reds-server,但它显示了以下错误消息

ReplyError: ERR wrong number of arguments for 'set' command
    at parseError (D:\Org\Projects\Up\Image metadata\Lab\Login with store\node_modules\redis-parser\lib\parser.js:179:12)
    at parseType (D:\Org\Projects\Up\Image metadata\Lab\Login with store\node_modules\redis-parser\lib\parser.js:302:14)

我的简单 node.js 快递应用程序如下

const express = require("express");
const session = require("express-session");
const redis = require("redis");
const connectRedis = require("connect-redis");
const bodyParser = require("body-parser");

const app = express();

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:true}));

const RedisStore = connectRedis(session);

const redisClient = redis.createClient({
    host:"localhost",
    port:6379
})


app.use(session({
    store: new RedisStore({client: redisClient}),
    secret:"shhhhh4",
    resave: false,
    saveUninitialized: false,
    cookie:{
        secure: false,
        httpOnly: false,
        maxAge: 5 * 30 * (24 * (1000 * 60 * 60))
    }
}));


app.get("/", (req,res)=>{
    const sess = req.session;
    if (sess.username && sess.password) {
        if (sess.username) {
            res.write(`<h1>Welcome ${sess.username} </h1><br>`)
            res.write(
                `<h3>This is the Home page</h3>`
            );
            res.end('<a href=' + '/logout' + '>Click here to log out</a >')
        }
    } else {
        res.sendFile(__dirname + "/login.html")
    }
});


app.post("/login", (req, res) => {
    const sess = req.session;
    const { username, password } = req.body
    sess.username = username
    sess.password = password
    console.log(req.body);
    // add username and password validation logic here if you want.If user is authenticated send the response as success
    res.end("success")
});

有什么问题?我已经安装了最新的导入模块,但仍然出现错误

我正在使用 Redis server version 2.4.5
和 redis 和 redis-connect 6.14.6

您需要更新到更新版本的 redis,因为您的版本已经过时并且不支持 set 命令的给定选项,请参阅此 github issue 了解更多详细信息。