Files
PMail/server/session/init.go
jinnrry c0f12558b5 init
2023-08-06 09:33:51 +08:00

26 lines
602 B
Go
Raw 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/alexedwards/scs/mysqlstore"
"github.com/alexedwards/scs/sqlite3store"
"github.com/alexedwards/scs/v2"
"pmail/config"
"pmail/db"
"time"
)
var Instance *scs.SessionManager
func Init() {
Instance = scs.New()
Instance.Lifetime = 24 * time.Hour
// 使用db存储session数据目前为了架构简单
// 暂不引入redis存储如果日后性能存在瓶颈可以将session迁移到redis
if config.Instance.DbType == "mysql" {
Instance.Store = mysqlstore.New(db.Instance.DB)
} else {
Instance.Store = sqlite3store.New(db.Instance.DB)
}
}