From 8bb1ab08104a909fe0c429a555e687f2ba41ccf0 Mon Sep 17 00:00:00 2001 From: orangix Date: Tue, 15 Aug 2023 20:58:34 +0200 Subject: [PATCH] cache user comments --- api/user.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/user.go b/api/user.go index 77d5ef1..1531e96 100644 --- a/api/user.go +++ b/api/user.go @@ -103,6 +103,11 @@ func (client *Client) FetchSubmissions(username string, sort string, page string } func (client *Client) FetchUserComments(username string, page string) ([]Comment, error) { + cacheData, found := client.Cache.Get(username + "-usercomments-" + page) + if found { + return cacheData.([]Comment), nil + } + req, err := http.NewRequest("GET", "https://api.imgur.com/comment/v1/comments", nil) if err != nil { return []Comment{}, err