我正在使用Redis来存储我的ExpressJS应用程序的会话数据,并且过去遇到了一些问题,其中持久性cookie使我的用户登录导致开发问题。 我试图用redis-cli清除会话数据,但是尽管运行了DEL KEYS *并且给出了(integer) 0响应,我仍然看到在运行KEYS *时会话出现。 任何人都可以帮我删除这些数据吗?
例:
127.0.0.1:6379> KEYS * 1) "sess:O7pchKqe-n7NUhP3lBANaf7LMjJG0U0a" 2) "sess:tSyQCCISPBpH88zT3MJjHw2tidttMdRs" 127.0.0.1:6379> DEL KEYS * (integer) 0 127.0.0.1:6379> KEYS * 1) "sess:O7pchKqe-n7NUhP3lBANaf7LMjJG0U0a" 2) "sess:tSyQCCISPBpH88zT3MJjHw2tidttMdRs"存储会话数据的ExpressJS代码:
var express = require('express'); var app = express(); var passport = require('passport'); var bodyParser = require('body-parser'); var cookieParser = require('cookie-parser'); var session = require('express-session'); var RedisStore = require('connect-redis')(session); var path = require('path'); //Port Setting var port = process.env.PORT || 3000; //Set Morgan as Logger app.use(morgan('dev')); //Extract POST Data app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); //Session Cookie app.use(cookieParser()); app.use(session({ store: new RedisStore({ host: '127.0.0.1', port: 6379 }), secret: 'super-secret', resave: true, saveUninitialized: true, cookie: { httpOnly: true, secure: false //turn to true on production once https is in place } }));I am using Redis to store my session data for my ExpressJS application and in the past have run into some issues where the persistent cookie is keeping my user logged in causing issues with development. I have tried to clear my session data with the redis-cli, but despite running DEL KEYS * and being given the (integer) 0 response, I still see the sessions appear when I run KEYS *. Can anyone help me with removing that data?
Example:
127.0.0.1:6379> KEYS * 1) "sess:O7pchKqe-n7NUhP3lBANaf7LMjJG0U0a" 2) "sess:tSyQCCISPBpH88zT3MJjHw2tidttMdRs" 127.0.0.1:6379> DEL KEYS * (integer) 0 127.0.0.1:6379> KEYS * 1) "sess:O7pchKqe-n7NUhP3lBANaf7LMjJG0U0a" 2) "sess:tSyQCCISPBpH88zT3MJjHw2tidttMdRs"ExpressJS code storing the session data:
var express = require('express'); var app = express(); var passport = require('passport'); var bodyParser = require('body-parser'); var cookieParser = require('cookie-parser'); var session = require('express-session'); var RedisStore = require('connect-redis')(session); var path = require('path'); //Port Setting var port = process.env.PORT || 3000; //Set Morgan as Logger app.use(morgan('dev')); //Extract POST Data app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); //Session Cookie app.use(cookieParser()); app.use(session({ store: new RedisStore({ host: '127.0.0.1', port: 6379 }), secret: 'super-secret', resave: true, saveUninitialized: true, cookie: { httpOnly: true, secure: false //turn to true on production once https is in place } }));最满意答案
(从评论转移)
我想你想要flushdb删除所有密钥。 del没有办法指定通配符,因此del keys *将尝试删除两个键:一个称为“keys”,另一个称为“*”。 响应0表示删除了0个键。
(transferring from comment)
I think you want flushdb to delete all keys. del doesn't have a way to specify a wildcard, so del keys * will try to delete two keys: one called "keys" and one called "*". The response 0 means that 0 keys were deleted.
更多推荐
发布评论