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
@@ -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.
