| 12345678910111213141516171819 |
- package session
- import (
- "github.com/alexedwards/scs/mysqlstore"
- "github.com/alexedwards/scs/v2"
- "pmail/mysql"
- "time"
- )
- var Instance *scs.SessionManager
- func Init() {
- Instance = scs.New()
- Instance.Lifetime = 24 * time.Hour
- // 使用mysql存储session数据,目前为了架构简单,
- // 暂不引入redis存储,如果日后性能存在瓶颈,可以将session迁移到redis
- Instance.Store = mysqlstore.New(mysql.Instance.DB)
- }
|