hotime/session.go
hoteas 3455fb0a1c style(cache): 格式化代码注释中的空格并添加 DISTINCT 选项
- 修复了缓存相关文件中注释开头缺少空格的问题
- 在 db/hotimedb.go 中为 vcond 数组添加了 "DISTINCT" 选项
- 注释掉了 session.go 中的并发控制代码以简化实现
2026-01-22 02:44:53 +08:00

64 lines
1.1 KiB
Go

package hotime
import (
. "code.hoteas.com/golang/hotime/cache"
. "code.hoteas.com/golang/hotime/common"
//"sync"
)
// session对象
type SessionIns struct {
*HoTimeCache
SessionId string
Map
ContextBase
//mutex sync.Mutex
}
func (that *SessionIns) set() {
that.HoTimeCache.Session(HEAD_SESSION_ADD+that.SessionId, that.Map)
}
func (that *SessionIns) Session(key string, data ...interface{}) *Obj {
if that.Map == nil {
that.get()
}
if len(data) != 0 {
if data[0] == nil {
//that.mutex.Lock()
delete(that.Map, key)
//that.mutex.Unlock()
that.set()
} else {
//that.mutex.Lock()
that.Map[key] = data[0]
//that.mutex.Unlock()
that.set()
}
return &Obj{Data: nil}
}
return &Obj{Data: that.Map.Get(key)}
}
func (that *SessionIns) get() {
that.Map = that.HoTimeCache.Session(HEAD_SESSION_ADD + that.SessionId).ToMap()
if that.Map != nil {
return
}
that.Map = Map{}
that.HoTimeCache.Session(HEAD_SESSION_ADD+that.SessionId, that.Map)
return
}
func (that *SessionIns) Init(cache *HoTimeCache) {
//that.mutex=sync.Mutex{}
that.HoTimeCache = cache
}