PMail/server/session/init.go
Jinnrry 054336fe9e
v2.6.1 (#169)
1、新增垃圾邮件过滤插件
2、使用使用github.com/dlclark/regexp2替换go原生的正则包
3、修复空数据导致的邮件插入失败
2024-07-20 10:39:17 +08:00

34 lines
897 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package session
import (
"github.com/Jinnrry/pmail/config"
"github.com/Jinnrry/pmail/db"
"github.com/alexedwards/scs/mysqlstore"
"github.com/alexedwards/scs/postgresstore"
"github.com/alexedwards/scs/sqlite3store"
"github.com/alexedwards/scs/v2"
"time"
)
var Instance *scs.SessionManager
func Init() {
Instance = scs.New()
Instance.Lifetime = 7 * 24 * time.Hour
// 使用db存储session数据目前为了架构简单
// 暂不引入redis存储如果日后性能存在瓶颈可以将session迁移到redis
switch config.Instance.DbType {
case config.DBTypeMySQL:
Instance.Store = mysqlstore.New(db.Instance.DB().DB)
case config.DBTypeSQLite:
Instance.Store = sqlite3store.New(db.Instance.DB().DB)
case config.DBTypePostgres:
Instance.Store = postgresstore.New(db.Instance.DB().DB)
default:
panic("Unsupported database type: " + config.Instance.DbType)
}
}