Skip to content

Commit

Permalink
cache release
Browse files Browse the repository at this point in the history
  • Loading branch information
Sianao committed Nov 26, 2024
1 parent 1cb1caa commit 17e5e8c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions router/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ func NewRouter(c *cache.Redis) *mux.Router {
vars := mux.Vars(r)
userBaisc := r.Context().Value(&moudule.B).([]string)
var address = fmt.Sprintf("https://github.com/%s/%s/releases/download/%s/%s", userBaisc[0], userBaisc[1], vars["version"], vars["file"])
c.Incr(address)
if c.Exists(address) {
path := fmt.Sprintf("github.com/%s/%s/releases/download/%s/%s", userBaisc[0], userBaisc[1], vars["version"], vars["file"])
c.Incr(path)
if c.Exists(path) {
r.URL.Path = path
http.FileServer(http.Dir("./cache")).ServeHTTP(w, r)
return
}
Expand All @@ -64,8 +66,11 @@ func NewRouter(c *cache.Redis) *mux.Router {
vars := mux.Vars(r)
userBaisc := r.Context().Value(&moudule.B).([]string)
var address = fmt.Sprintf("https://github.com/%s/%s/archive/refs/tags/%s", userBaisc[0], userBaisc[1], vars["tags"])
c.Incr(address)
if c.Exists(address) {
path := fmt.Sprintf("github.com/%s/%s/archive/refs/tags/%s",
userBaisc[0], userBaisc[1], r.URL.Path)
c.Incr(path)
if c.Exists(path) {
r.URL.Path = path
http.FileServer(http.Dir("./cache")).ServeHTTP(w, r)
return
}
Expand Down

0 comments on commit 17e5e8c

Please sign in to comment.