Skip to content

Commit

Permalink
fix: using RPUSH instead of LPUSH to append to right of the current list
Browse files Browse the repository at this point in the history
  • Loading branch information
huantt committed Oct 19, 2023
1 parent f67b59d commit 402982a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions migrator/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,10 @@ func migrateList(oldClient redis.Conn, newClient redis.Conn, key string) error {
logrus.Errorf("Not able to get the elements for key %s: %v", key, err)
}
var data = []interface{}{key}
for i := len(elements) - 1; i >= 0; i-- {
data = append(data, elements[i])
for _, element := range elements {
data = append(data, element)
}
// LPUSH: Elements are inserted one after the other to the head of the list, from the leftmost element to the rightmost element.
// So for instance the command LPUSH mylist a b c will result into a list containing c as first element, b as second element and a as third element
_, err = newClient.Do("LPUSH", data...)
_, err = newClient.Do("RPUSH", data...)
if err != nil {
return fmt.Errorf("error while pushing list keys %v", err)
}
Expand Down

0 comments on commit 402982a

Please sign in to comment.