From 19526aa0e6d9363a27cc9907ef5c2f316ec3e4fb Mon Sep 17 00:00:00 2001 From: xtrafrancyz Date: Fri, 3 Apr 2020 15:12:56 +0300 Subject: [PATCH] Fix mysql cache --- backend/mysql.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/mysql.go b/backend/mysql.go index e875fb0..3bdc991 100644 --- a/backend/mysql.go +++ b/backend/mysql.go @@ -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