缓存驱动更换成功,支持3级缓存,memory,以及db

This commit is contained in:
hoteas
2021-05-28 22:52:22 +08:00
parent fc315064e7
commit 1101937028
11 changed files with 369 additions and 126 deletions
+9 -29
View File
@@ -7,22 +7,14 @@ import (
//session对象
type SessionIns struct {
ShortCache CacheIns
LongCache CacheIns
SessionId string
*HoTimeCache
SessionId string
Map
ContextBase
}
func (that *SessionIns) set() {
if that.ShortCache != nil {
that.ShortCache.Cache(HEAD_SESSION_ADD+that.SessionId, that.Map)
}
if that.LongCache != nil {
that.LongCache.Cache(HEAD_SESSION_ADD+that.SessionId, that.Map)
}
that.HoTimeCache.Session(HEAD_SESSION_ADD+that.SessionId, that.Map)
}
func (that *SessionIns) Session(key string, data ...interface{}) *Obj {
@@ -48,29 +40,17 @@ func (that *SessionIns) Session(key string, data ...interface{}) *Obj {
func (that *SessionIns) get() {
if that.ShortCache != nil {
that.Map = that.ShortCache.Cache(HEAD_SESSION_ADD + that.SessionId).ToMap()
if that.Map != nil {
return
}
that.Map = that.HoTimeCache.Session(HEAD_SESSION_ADD + that.SessionId).ToMap()
if that.Map != nil {
return
}
if that.LongCache != nil {
that.Map = that.LongCache.Cache(HEAD_SESSION_ADD + that.SessionId).ToMap()
if that.Map != nil {
if that.ShortCache != nil {
that.ShortCache.Cache(HEAD_SESSION_ADD+that.SessionId, that.Map)
}
return
}
}
that.Map = Map{}
that.ShortCache.Cache(HEAD_SESSION_ADD+that.SessionId, that.Map)
that.HoTimeCache.Session(HEAD_SESSION_ADD+that.SessionId, that.Map)
return
}
func (that *SessionIns) Init(short CacheIns, long CacheIns) {
that.ShortCache = short
that.LongCache = long
func (that *SessionIns) Init(cache *HoTimeCache) {
that.HoTimeCache = cache
}