缓存驱动更换成功,支持3级缓存,memory,以及db
This commit is contained in:
+9
-29
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user