Skip to content

Commit cef0b4e

Browse files
Added error handling redis
1 parent df11061 commit cef0b4e

File tree

1 file changed

+0
-42
lines changed

1 file changed

+0
-42
lines changed

internal/session/sessredis.go

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package session
33
import (
44
"context"
55
"fmt"
6-
"time"
76
)
87

98
/* TODO: make the operations below thread safe with mutexes*/
@@ -26,47 +25,6 @@ func (m *Manager) saveSessionRedis(session *Session) error {
2625
return nil
2726
}
2827

29-
/* update expiry time in session */
30-
func (m *Manager) updateSessionExpiryRedis(session *Session) error {
31-
32-
/*
33-
function expects that new expiry time is already set in the session
34-
*/
35-
36-
ctx := context.Background()
37-
38-
/* create a key for Redis operation */
39-
key := fmt.Sprintf("session:%s", session.ID)
40-
41-
/* convert the expiry time to */
42-
formattedExpiry := session.Expiry.Format(time.RFC3339)
43-
44-
/* update just the expiry field */
45-
err := m.redis.HSet(ctx, key, "expiry", formattedExpiry).Err()
46-
if err != nil {
47-
return fmt.Errorf("failed to update session expiry in Redis: %w", err)
48-
}
49-
50-
return nil
51-
}
52-
53-
/* update status of the session - update and set expired operations will be done with this */
54-
func (m *Manager) updateSessionStatusRedis(session *Session, status Status) error {
55-
56-
ctx := context.Background()
57-
58-
/* create a key for Redis operation */
59-
key := fmt.Sprintf("session:%s", session.ID)
60-
61-
/* update the session status */
62-
err := m.redis.HSet(ctx, key, "status", status).Err()
63-
if err != nil {
64-
return fmt.Errorf("failed to mark session as expired in Redis: %w", err)
65-
}
66-
67-
return nil
68-
}
69-
7028
/* increment the failed field of the session in Redis */
7129
func (m *Manager) IncrementSessionFailedRedis(session *Session) error {
7230
ctx := context.Background()

0 commit comments

Comments
 (0)