pico

created pr with 62.1 on 2025-04-08T15:27:23Z · by c8ef7d19
cmds
checkout latest patchset:
ssh pr.pico.sh print 62 | git am -3
checkout any patchset in a patch request:
ssh pr.pico.sh print 62.[rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 62

Patchset 62.1 on 2025-04-08T15:27:23Z · commit 21ef055

+12 -1 pkg/shared/router.go #
......@@ -10,6 +10,8 @@ import (
1010 "regexp"
1111 "strings"
1212
13+ "github.com/hashicorp/golang-lru/v2/expirable"
14+ "github.com/picosh/pico/pkg/cache"
1315 "github.com/picosh/pico/pkg/db"
1416 "github.com/picosh/pico/pkg/pssh"
1517 "github.com/picosh/pico/pkg/shared/storage"
......@@ -211,15 +213,24 @@ func GetSubdomain(r *http.Request) string {
211213 return r.Context().Value(CtxSubdomainKey{}).(string)
212214 }
213215
216+var txtCache = expirable.NewLRU[string, string](2048, nil, cache.CacheTimeout)
217+
214218 func GetCustomDomain(host string, space string) string {
215219 txt := fmt.Sprintf("_%s.%s", space, host)
220+ record, found := txtCache.Get(txt)
221+ if found {
222+ return record
223+ }
224+
216225 records, err := net.LookupTXT(txt)
217226 if err != nil {
218227 return ""
219228 }
220229
221230 for _, v := range records {
222- return strings.TrimSpace(v)
231+ rec := strings.TrimSpace(v)
232+ txtCache.Add(txt, rec)
233+ return rec
223234 }
224235
225236 return ""
Back to top