Skip to content

Commit 0cc282f

Browse files
Made it to store pending and results into different lists in Redis
1 parent 8b1282e commit 0cc282f

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

internal/session/redis.go

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ func (m *Manager) updateSessionExpiryRedis(session *Session) error {
4040

4141
ctx := context.Background()
4242

43-
/* thread safety for the session */
44-
// session.Mutex.Lock()
45-
// defer session.Mutex.Unlock()
46-
4743
/* create a key for Redis operation */
4844
key := fmt.Sprintf("session:%s", session.ID)
4945

@@ -64,10 +60,6 @@ func (m *Manager) updateSessionStatusRedis(session *Session, status Status) erro
6460

6561
ctx := context.Background()
6662

67-
/* thread safety for the session */
68-
// session.Mutex.Lock()
69-
// defer session.Mutex.Unlock()
70-
7163
/* create a key for Redis operation */
7264
key := fmt.Sprintf("session:%s", session.ID)
7365

@@ -81,19 +73,15 @@ func (m *Manager) updateSessionStatusRedis(session *Session, status Status) erro
8173
}
8274

8375
/* save transaction results to redis */
84-
func (m *Manager) saveTransactionResultsRedis(session *Session, txResult types.Transaction) error {
76+
func (m *Manager) SaveTransactionResultsRedis(session *Session, txResult *types.Transaction, list string) error {
8577

8678
ctx := context.Background()
8779

88-
/* thread safety for the session */
89-
// session.Mutex.Lock()
90-
// defer session.Mutex.Unlock()
91-
9280
/* get the session ID */
9381
sessionID := session.ID
9482

9583
/* create a key for Redis operation */
96-
key := fmt.Sprintf("session:%s:txresults", sessionID)
84+
key := fmt.Sprintf("session:%s:%s", sessionID, list)
9785

9886
/* marshal transaction result to JSON */
9987
resultBytes, err := json.Marshal(txResult)
@@ -105,6 +93,8 @@ func (m *Manager) saveTransactionResultsRedis(session *Session, txResult types.T
10593
return m.redis.RPush(ctx, key, resultBytes).Err()
10694
}
10795

96+
func (m *Manager) UpdateTransactionStatusRedis(session *Session, txResult types.Transaction) {}
97+
10898
func (m *Manager) getTransactionResultsRedis(session *Session, limit int) ([]types.Transaction, error) {
10999
ctx := context.Background()
110100

0 commit comments

Comments
 (0)