picgo/corelib/session.go

21 lines
452 B
Go
Raw Permalink Normal View History

2024-07-12 20:32:33 +08:00
package corelib
import (
"github.com/boj/redistore"
2024-07-12 20:32:33 +08:00
"picgo/configs"
)
var SessionStore *redistore.RediStore
func NewSessionStore() {
// Fetch new store.
store, err := redistore.NewRediStore(10, "tcp", configs.Settings.Redis.Addr, configs.Settings.Redis.Password, []byte(configs.Settings.SessionsKey))
2024-07-12 20:32:33 +08:00
if err != nil {
panic(err)
}
2024-08-01 20:40:06 +08:00
// session过期时间24小时
store.SetMaxAge(1 * 24 * 3600)
2024-07-12 20:32:33 +08:00
SessionStore = store
//defer store.Close()
2024-07-12 20:32:33 +08:00
}