INNER CODE UNIT · Go
NewContext
arp242/goatcounter · context.go:155
func NewContext(ctx context.Context, db zdb.DB) context.Context {
n := zdb.WithDB(context.Background(), db)
n = geo.With(n, geo.Get(ctx))
n = NewCache(n)
n = NewConfig(n)
m := blackmail.Get(ctx)
if m != nil {
m = blackmail.NewWriter(os.Stderr)
}
n = blackmail.With(n, m)
return n
}
func NewCache(ctx context.Context) context.Context {
s := zcache.New[SiteID, *Site](24*time.Hour, 1*time.Hour)
ctx = context.WithValue(ctx, keyCacheSites, s)
ctx = context.WithValue(ctx, keyCacheSitesProxy, zcache.NewProxy[string, SiteID, *Site](s))