Skip to content

Commit

Permalink
fix redis sessionb db print an error when session created for first t…
Browse files Browse the repository at this point in the history
…ime...
  • Loading branch information
kataras committed Sep 30, 2017
1 parent 1b677c3 commit 2f4f0a0
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions sessiondb/redis/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,20 @@ func (db *Database) Load(sid string) (storeDB sessions.RemoteStore) {

// fetch the values from this session id and copy-> store them
storeMaybe, err := db.redis.Get(sid)
if err != nil {
golog.Errorf("error while trying to load session values(%s) from redis: %v", sid, err)
return
}

storeB, ok := storeMaybe.([]byte)
if !ok {
golog.Errorf("something wrong, store should be stored as []byte but stored as %#v", storeMaybe)
return
}
// not exists yet, no problem return an empty remote store.
if err == nil {
storeB, ok := storeMaybe.([]byte)
if !ok {
golog.Errorf("something wrong, store should be stored as []byte but stored as %#v", storeMaybe)
return
}

storeDB, err = sessions.DecodeRemoteStore(storeB) // decode the whole value, as a remote store
if err != nil {
golog.Errorf(`error while trying to load session values(%s) from redis:
the retrieved value is not a sessions.RemoteStore type, please report that as bug, that should never occur: %v`,
sid, err)
storeDB, err = sessions.DecodeRemoteStore(storeB) // decode the whole value, as a remote store
if err != nil {
golog.Errorf(`error while trying to load session values(%s) from redis:
the retrieved value is not a sessions.RemoteStore type, please report that as bug, that should never occur: %v`,
sid, err)
}
}

return
Expand Down

0 comments on commit 2f4f0a0

Please sign in to comment.