update session info
This commit is contained in:
@@ -85,7 +85,24 @@ func (m *RedisStore) Get(sessionID string) (*SessionData, error) {
|
||||
}
|
||||
return &session_data, nil
|
||||
}
|
||||
|
||||
func (m *RedisStore) Update(sessionID string, session *SessionData) error {
|
||||
hashedSession := hashSession(sessionID)
|
||||
|
||||
data, err := json.Marshal(*session)
|
||||
if err != nil {
|
||||
return ErrSessionBackend
|
||||
}
|
||||
|
||||
updated, err := m.client.SetXX(m.ctx, hashedSession, data, 0).Result()
|
||||
if err != nil {
|
||||
logging.Error(err.Error())
|
||||
return ErrSessionBackend
|
||||
}
|
||||
|
||||
if !updated {
|
||||
return ErrSessionNotFound
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user