cache user comments

This commit is contained in:
orangix 2023-08-15 20:58:34 +02:00
parent 52dbf0195d
commit 8bb1ab0810
No known key found for this signature in database
GPG Key ID: C31D4A86601C8416

View File

@ -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