Skip to content

Commit

Permalink
fix redis sessiondb expiration
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kataras committed Aug 20, 2017
1 parent a1adc73 commit 85cfc91
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sessions/sessiondb/redis/database.go
Expand Up @@ -2,6 +2,7 @@ package redis

import (
"runtime"
"time"

"github.com/kataras/golog"
"github.com/kataras/iris/sessions"
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 85cfc91

Please sign in to comment.