From 57ec9939ab67a4cc89d992dbdf53e19375d453ff Mon Sep 17 00:00:00 2001 From: Lyric-c Date: Fri, 18 Aug 2023 10:28:52 +0800 Subject: [PATCH] =?UTF-8?q?feed=E5=86=85=E5=AE=B9=E6=97=A0=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=97=B6=E6=97=A0=E9=9C=80=E6=9B=B4=E6=96=B0=E7=BC=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index ce74756..d162f6b 100644 --- a/main.go +++ b/main.go @@ -128,6 +128,13 @@ func updateFeed(fp *gofeed.Parser, url, formattedTime string) { log.Printf("Error fetching feed: %v | %v", url, err) return } + //feed内容无更新时无需更新缓存 + if cache, ok := dbMap[url]; ok && + len(result.Items) > 0 && + len(cache.Items) > 0 && + result.Items[0].Link == cache.Items[0].Link { + return + } customFeed := feed{ Title: result.Title, Link: result.Link, @@ -136,8 +143,8 @@ func updateFeed(fp *gofeed.Parser, url, formattedTime string) { } for _, v := range result.Items { customFeed.Items = append(customFeed.Items, item{ - Link: v.Link, - Title: v.Title, + Link: v.Link, + Title: v.Title, Description: v.Description, }) }