mirror of
https://github.com/kataras/iris.git
synced 2025-03-13 21:36:28 +01:00
fix redis sessiondb expiration
I don't know why I did add LifeTime.Second() back then, it was silly of me but didn't receive any reports except a commit comment 25 minutes ago, so we can assume that redis is almost "dead" nowdays. Thank you for the notice @sy264115809 Former-commit-id: 140caa2a42aa16b1e80905d24976c481eae24c69
This commit is contained in:
parent
4099bd15c1
commit
996961dd86
|
@ -2,6 +2,7 @@ package redis
|
|||
|
||||
import (
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/kataras/golog"
|
||||
"github.com/kataras/iris/sessions"
|
||||
|
@ -84,7 +85,14 @@ func (db *Database) sync(p sessions.SyncPayload) {
|
|||
return
|
||||
}
|
||||
|
||||
db.redis.Set(p.SessionID, storeB, p.Store.Lifetime.Second())
|
||||
// not expire if zero
|
||||
seconds := 0
|
||||
|
||||
if lifetime := p.Store.Lifetime; !lifetime.IsZero() {
|
||||
seconds = int(lifetime.Sub(time.Now()).Seconds())
|
||||
}
|
||||
|
||||
db.redis.Set(p.SessionID, storeB, seconds)
|
||||
}
|
||||
|
||||
// Close shutdowns the redis connection.
|
||||
|
|
Loading…
Reference in New Issue
Block a user