1
0
mirror of https://github.com/astaxie/beego.git synced 2025-06-12 13:20:40 +00:00

Adapter: session module

This commit is contained in:
Ming Deng
2020-09-03 23:36:09 +08:00
parent 3530457ff9
commit 8ef9965eef
23 changed files with 2395 additions and 4 deletions

View File

@ -172,7 +172,7 @@ func (pder *CookieProvider) SessionAll(context.Context) int {
}
// SessionUpdate Implement method, no used.
func (pder *CookieProvider) SessionUpdate(sid string) error {
func (pder *CookieProvider) SessionUpdate(ctx context.Context, sid string) error {
return nil
}

View File

@ -96,7 +96,7 @@ func (pder *MemProvider) SessionInit(ctx context.Context, maxlifetime int64, sav
func (pder *MemProvider) SessionRead(ctx context.Context, sid string) (Store, error) {
pder.lock.RLock()
if element, ok := pder.sessions[sid]; ok {
go pder.SessionUpdate(sid)
go pder.SessionUpdate(nil, sid)
pder.lock.RUnlock()
return element.Value.(*MemSessionStore), nil
}
@ -123,7 +123,7 @@ func (pder *MemProvider) SessionExist(ctx context.Context, sid string) (bool, er
func (pder *MemProvider) SessionRegenerate(ctx context.Context, oldsid, sid string) (Store, error) {
pder.lock.RLock()
if element, ok := pder.sessions[oldsid]; ok {
go pder.SessionUpdate(oldsid)
go pder.SessionUpdate(nil, oldsid)
pder.lock.RUnlock()
pder.lock.Lock()
element.Value.(*MemSessionStore).sid = sid
@ -181,7 +181,7 @@ func (pder *MemProvider) SessionAll(context.Context) int {
}
// SessionUpdate expand time of session store by id in memory session
func (pder *MemProvider) SessionUpdate(sid string) error {
func (pder *MemProvider) SessionUpdate(ctx context.Context, sid string) error {
pder.lock.Lock()
defer pder.lock.Unlock()
if element, ok := pder.sessions[sid]; ok {