Documentation
¶
Index ¶
- Constants
- Variables
- func Decode(sid string) (uid string, err error)
- func Encode(uid string) (sid string, err error)
- func NewSetter(id string, data any) storage.Setter
- type Data
- func (this *Data) Atomic() int32
- func (this *Data) Heartbeat(v ...int32) int32
- func (this *Data) Id() string
- func (this *Data) Index() int32
- func (this *Data) Is(v *Data) bool
- func (this *Data) KeepAlive()
- func (this *Data) Merge(p *Data, locked ...bool)
- func (this *Data) Reset()
- func (this *Data) Set(key string, value any, locked ...bool) any
- func (this *Data) TryResetIndex()
- func (this *Data) UUID() string
- func (this *Data) Update(data map[string]any, locked ...bool)
- type Memory
- type Redis
- type Session
- func (this *Session) Create(uuid string, data map[string]any) (token string, err error)
- func (this *Session) Delete() (err error)
- func (this *Session) Release()
- func (this *Session) Set(key string, val any)
- func (this *Session) Update(vs map[string]any)
- func (this *Session) Verify(token string) (err error)
- type Setter
- type Storage
Constants ¶
View Source
const ContextRandomStringLength = 4
Variables ¶
View Source
var ( ErrorStorageNotSet = values.Errorf(201, "session Storage not set") ErrorSessionIdEmpty = values.Errorf(202, "session id empty") ErrorSessionLocked = values.Errorf(203, "session locked") ErrorSessionTypeError = values.Errorf(204, "session type error") ErrorSessionNotExist = values.Errorf(205, "session not exist") ErrorSessionTypeExpire = values.Errorf(206, "session expire") ErrorSessionIllegal = values.Errorf(207, "session illegal") ErrorSessionUnknown = values.Errorf(208, "session unknown error") ErrorSessionReplaced = values.Errorf(209, "session replaced") ErrorSessionSecretIllegal = values.Errorf(210, "session secret illegal") )
View Source
var Heartbeat int32 = 10 //心跳(S)
View Source
var MaxDataIndex = int32(math.MaxInt32 - 1000)
View Source
var Options = struct { Name string //session cookie name Token token //token生成和解析方式 MaxAge int64 //有效期(S) Secret string //16位秘钥 Storage Storage }{ Name: "_cookie_vars", MaxAge: 3600, Secret: "UVFGHIJABCopqDNO", }
Functions ¶
Types ¶
type Data ¶
Data 用户登录信息,不要直接修改 Player.Values 信息
func (*Data) TryResetIndex ¶
func (this *Data) TryResetIndex()
type Memory ¶
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
type Session ¶
type Session struct { *Data // contains filtered or unexported fields }
type Storage ¶
type Storage interface { New(data *Data) error //同Create Verify(token string) (data *Data, err error) //验证TOKEN信息 Create(uuid string, value map[string]any) (data *Data, err error) //用户登录创建新session Update(data *Data, value map[string]any) error //更新session数据 Delete(data *Data) error //退出登录删除SESSION //关闭服务器时断开连接等 }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.