import {Store} from 'koa-session2'
export default class memstore extends Store {
constructor()
{
super()
this.store = {}
}
get(sid)
{
const data = this.store[`SESSION:${sid}`]
return JSON.parse(data)
}
set(session, opts)
{
if (!opts.sid)
{
opts.sid = this.getID(24)
}
this.store[`SESSION:${opts.sid}`] = JSON.stringify(session)
return opts.sid
}
destroy(sid)
{
delete this.store[`SESSION:${sid}`]
}
}