observable-redis-session
A session module that uses Object.observe()
to set values to Redis atomically and asynchronously.
Usage:
const app = app uri: 'tcp://localhost:6379' app app
API
session(app, options)
Adds this.session()
to the app.
Options:
.uri
- Redis URI.client
- Redis client, if not set by.uri
.length
- session id key byte length, default10
.prefix
- Redis key prefix, defaulthash:koa-session:
.maxAge
- max session age, default30 days
let session = yield this.session()
Grab the session asynchronously.
session.touch()
Update the session without changing the values on the server.
session.destroy()
Destroy the session.
let session = session.regenerate()
Destroy the old session and return a new one.
session.maxAge=
Set the max age for this session, defaulting to options.maxAge
.
Caveats
- You must always
yield setImmediate
upstream to allowObject.observe()
time to execute its callback.