mirror of
				https://github.com/Jinnrry/PMail.git
				synced 2025-10-31 11:56:21 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			20 lines
		
	
	
		
			446 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			446 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 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)
 | ||
| }
 | 
