Skip to content

Commit 84a61bf

Browse files
Updated for storing transactions in list
1 parent 6bd1909 commit 84a61bf

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

internal/session/txnredis.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,24 @@ func (m *Manager) getTransactionResultsRedis(session *Session, limit int) ([]typ
7070

7171
return results, nil
7272
}
73+
74+
/* save transaction results to redis */
75+
func (m *Manager) SaveTransactionRedisList(session *Session, txResult *types.Transaction, list string) error {
76+
77+
ctx := context.Background()
78+
79+
/* get the session ID */
80+
sessionID := session.ID
81+
82+
/* create a key for Redis operation */
83+
key := fmt.Sprintf("session:%s:%s", sessionID, list)
84+
85+
/* marshal transaction result to JSON */
86+
resultBytes, err := json.Marshal(txResult)
87+
if err != nil {
88+
return fmt.Errorf("failed to marshal transaction result: %w", err)
89+
}
90+
91+
/* push the transaction result in the back of the list */
92+
return m.redis.RPush(ctx, key, resultBytes).Err()
93+
}

0 commit comments

Comments
 (0)