Skip to content

Commit e9c55d3

Browse files
authored
Merge pull request #428 from damongolding/feature/about
Feature/caching for about page
2 parents c87111d + f071037 commit e9c55d3

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

internal/templates/views/views_about.templ

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"fmt"
77
"github.com/charmbracelet/log"
8+
"github.com/damongolding/immich-kiosk/internal/cache"
89
"github.com/damongolding/immich-kiosk/internal/common"
910
"github.com/damongolding/immich-kiosk/internal/config"
1011
"github.com/damongolding/immich-kiosk/internal/immich"
@@ -126,6 +127,15 @@ func getLatestRelease(owner, repo string) (string, string) {
126127
url := fmt.Sprintf("https://api.github.com/repos/%s/%s/releases/latest", owner, repo)
127128
link := fmt.Sprintf("https://github.com/%s/%s/releases/latest", owner, repo)
128129

130+
if tagData, found := cache.Get(url); found {
131+
log.Debug("Github release cache hit", "url", url)
132+
tag, ok := tagData.(GitHubRelease)
133+
if ok {
134+
return tag.TagName, link
135+
}
136+
log.Debug("Github release cache data type assertion failed", "url", url)
137+
}
138+
129139
client := &http.Client{
130140
Timeout: 10 * time.Second,
131141
}
@@ -155,5 +165,7 @@ func getLatestRelease(owner, repo string) (string, string) {
155165

156166
link = fmt.Sprintf("https://github.com/%s/%s/releases/tag/%s", owner, repo, release.TagName)
157167

168+
cache.Set(url, release)
169+
158170
return release.TagName, link
159171
}

0 commit comments

Comments
 (0)