mirror of
https://github.com/kataras/iris.git
synced 2025-02-09 02:34:55 +01:00
This commit is contained in:
parent
b93ac27034
commit
084b689d37
|
@ -185,6 +185,7 @@ func (p *sessionProvider) read(sid string) *session {
|
||||||
p.mu.Lock()
|
p.mu.Lock()
|
||||||
if elem, found := p.sessions[sid]; found {
|
if elem, found := p.sessions[sid]; found {
|
||||||
p.mu.Unlock() // yes defer is slow
|
p.mu.Unlock() // yes defer is slow
|
||||||
|
elem.Value.(*session).lastAccessedTime = time.Now()
|
||||||
return elem.Value.(*session)
|
return elem.Value.(*session)
|
||||||
}
|
}
|
||||||
p.mu.Unlock()
|
p.mu.Unlock()
|
||||||
|
@ -233,7 +234,8 @@ func (p *sessionProvider) gc(duration time.Duration) {
|
||||||
|
|
||||||
// if the time has passed. session was expired, then delete the session and its memory place
|
// if the time has passed. session was expired, then delete the session and its memory place
|
||||||
// we are not destroy the session completely for the case this is re-used after
|
// we are not destroy the session completely for the case this is re-used after
|
||||||
if (elem.Value.(*session).lastAccessedTime.Unix() + duration.Nanoseconds()) < time.Now().Unix() {
|
|
||||||
|
if time.Now().After(elem.Value.(*session).lastAccessedTime.Add(duration)) {
|
||||||
p.list.Remove(elem)
|
p.list.Remove(elem)
|
||||||
delete(p.sessions, elem.Value.(*session).sid)
|
delete(p.sessions, elem.Value.(*session).sid)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user