1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-25 18:10:55 +00:00
This commit is contained in:
astaxie 2013-07-31 21:36:10 +08:00
parent 485d89d5c8
commit c83d03c298

View File

@ -9,8 +9,8 @@ import (
var mempder = &MemProvider{list: list.New(), sessions: make(map[string]*list.Element)} var mempder = &MemProvider{list: list.New(), sessions: make(map[string]*list.Element)}
type MemSessionStore struct { type MemSessionStore struct {
sid string //session id唯一标示 sid string //session id唯一标示
timeAccessed time.Time //最后访问时间 timeAccessed time.Time //最后访问时间
value map[interface{}]interface{} //session里面存储的值 value map[interface{}]interface{} //session里面存储的值
lock sync.RWMutex lock sync.RWMutex
} }
@ -113,8 +113,8 @@ func (pder *MemProvider) SessionGC() {
} }
func (pder *MemProvider) SessionUpdate(sid string) error { func (pder *MemProvider) SessionUpdate(sid string) error {
pder.lock.RLock() pder.lock.Lock()
defer pder.lock.RUnlock() defer pder.lock.Unlock()
if element, ok := pder.sessions[sid]; ok { if element, ok := pder.sessions[sid]; ok {
element.Value.(*MemSessionStore).timeAccessed = time.Now() element.Value.(*MemSessionStore).timeAccessed = time.Now()
pder.list.MoveToFront(element) pder.list.MoveToFront(element)