You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
971 B
Go
54 lines
971 B
Go
package session
|
|
|
|
// Session Session接口
|
|
type Session interface {
|
|
// ID 获取Session ID
|
|
ID() string
|
|
|
|
// Get 获取值
|
|
Get(key string) (interface{}, error)
|
|
|
|
// Set 设置值
|
|
Set(key string, value interface{}) error
|
|
|
|
// Delete 删除值
|
|
Delete(key string) error
|
|
|
|
// Clear 清空所有值
|
|
Clear() error
|
|
|
|
// IsNew 检查是否是新的Session
|
|
IsNew() bool
|
|
}
|
|
|
|
// Storage Session存储接口
|
|
type Storage interface {
|
|
// Get 获取Session
|
|
Get(sessionID string) (Session, error)
|
|
|
|
// Create 创建Session
|
|
Create(sessionID string) (Session, error)
|
|
|
|
// Delete 删除Session
|
|
Delete(sessionID string) error
|
|
|
|
// Save 保存Session
|
|
Save(session Session) error
|
|
|
|
// Cleanup 清理过期Session
|
|
Cleanup() error
|
|
}
|
|
|
|
// Manager Session管理器接口
|
|
type Manager interface {
|
|
// Get 获取Session
|
|
Get(sessionID string) (Session, error)
|
|
|
|
// Create 创建Session
|
|
Create(sessionID string) (Session, error)
|
|
|
|
// Delete 删除Session
|
|
Delete(sessionID string) error
|
|
}
|
|
|