Skip to content

Commit

Permalink
Fix mysql cache
Browse files Browse the repository at this point in the history
  • Loading branch information
xtrafrancyz committed Apr 3, 2020
1 parent 3cac3b0 commit 19526aa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions backend/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,14 @@ func (s *Mysql) GetAllLinks() []*Link {
link := &internalLink{
Link: &Link{},
}
link.use()
err = rows.Scan(&link.Slug, &link.Url, &link.Clicks, &link.Created)
if err != nil {
log.Println("mysql error: ", err)
break
}
s.cache.Store(link.Slug, link)
stored, _ := s.cache.LoadOrStore(link.Slug, link)
link = stored.(*internalLink)
link.use()
list = append(list, link.Link)
}
return list
Expand Down

0 comments on commit 19526aa

Please sign in to comment.