框架基本完成

This commit is contained in:
hoteas
2017-08-10 10:14:56 +00:00
parent e02a80fda8
commit b07bc3c9b9
8 changed files with 242 additions and 203 deletions
+34 -38
View File
@@ -1,75 +1,71 @@
package hotime
//session对象
type SessionIns struct {
ShortCache CacheIns
LongCache CacheIns
SessionId string
LongCache CacheIns
SessionId string
Map
Error
}
func (this *SessionIns)set(){
if this.ShortCache!=nil{
this.ShortCache.Cache(SESSION_TYPE+this.SessionId,this.Map)
}
if this.LongCache!=nil{
this.LongCache.Cache(SESSION_TYPE+this.SessionId,this.Map)
}
func (this *SessionIns) set() {
if this.ShortCache != nil {
this.ShortCache.Cache(SESSION_TYPE+this.SessionId, this.Map)
}
if this.LongCache != nil {
this.LongCache.Cache(SESSION_TYPE+this.SessionId, this.Map)
}
}
func (this *SessionIns) Session(key string, data ...interface{}) *Obj {
func(this *SessionIns)Session(key string,data ...interface{})*Obj{
if this.Map==nil{
if this.Map == nil {
this.get()
}
if len(data)!=0{
if data[0]==nil{
delete(this.Map,key)
if len(data) != 0 {
if data[0] == nil {
delete(this.Map, key)
this.set()
}else{
this.Map[key]=data[0]
} else {
this.Map[key] = data[0]
this.set()
}
return &Obj{Data:nil}
return &Obj{Data: nil}
}
return &Obj{Data:this.Map.Get(key)}
return &Obj{Data: this.Map.Get(key)}
}
func (this *SessionIns)get(){
func (this *SessionIns) get() {
if this.ShortCache!=nil{
this.Map=this.ShortCache.Cache(SESSION_TYPE+this.SessionId).ToMap()
if this.Map!=nil{
if this.ShortCache != nil {
this.Map = this.ShortCache.Cache(SESSION_TYPE + this.SessionId).ToMap()
if this.Map != nil {
return
}
}
if this.LongCache!=nil{
this.Map=this.LongCache.Cache(SESSION_TYPE+this.SessionId).ToMap()
if this.Map!=nil{
if this.ShortCache!=nil{
this.ShortCache.Cache(SESSION_TYPE+this.SessionId,this.Map)
if this.LongCache != nil {
this.Map = this.LongCache.Cache(SESSION_TYPE + this.SessionId).ToMap()
if this.Map != nil {
if this.ShortCache != nil {
this.ShortCache.Cache(SESSION_TYPE+this.SessionId, this.Map)
}
return
}
}
this.Map=Map{}
this.ShortCache.Cache(SESSION_TYPE+this.SessionId,this.Map)
this.Map = Map{}
this.ShortCache.Cache(SESSION_TYPE+this.SessionId, this.Map)
return
}
func (this *SessionIns)Init(short CacheIns, long CacheIns){
this.ShortCache=short
this.LongCache=long
}
func (this *SessionIns) Init(short CacheIns, long CacheIns) {
this.ShortCache = short
this.LongCache = long
}