Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

will redis delete my old express.js sessions?

i'm using redis as my session store for a node.js + express app...will it automatically delete old sessions after they expire?

...or do I need to do some cleanup on the server side? (so the db doesn't grow too large)

  var RedisStore = require('connect-redis')(express)

  app.use(express.session({
    store: new RedisStore({
      host: cfg.redis.host,
      db: cfg.redis.db
    }), 
    secret: 'foobar'
  }));
like image 445
chovy Avatar asked Sep 23 '12 06:09

chovy


1 Answers

It's working as expected. If I do a browser-only session (expires cookie when user-agent closes) then it lives in redis for 24 hours (I did not set a ttl option in connect-redis).

If I set a cookie to expire in 2 weeks, it lives in redis for 14 days.

You can check with these commands:

start redis-cli
> keys *
> ttl <key>
like image 107
chovy Avatar answered Oct 29 '22 01:10

chovy