cache followers collection too to reduce garbage
This commit is contained in:
parent
c0e8e1d74a
commit
ed682de765
37
web.go
37
web.go
|
@ -651,6 +651,23 @@ func outbox(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var oldempties = cache.New(cache.Options{Filler: func(url string) ([]byte, bool) {
|
||||||
|
colname := "/followers"
|
||||||
|
if strings.HasSuffix(url, "/following") {
|
||||||
|
colname = "/following"
|
||||||
|
}
|
||||||
|
user := fmt.Sprintf("https://%s%s", serverName, url[:len(url)-10])
|
||||||
|
j := junk.New()
|
||||||
|
j["@context"] = itiswhatitis
|
||||||
|
j["id"] = user + colname
|
||||||
|
j["attributedTo"] = user
|
||||||
|
j["type"] = "OrderedCollection"
|
||||||
|
j["totalItems"] = 0
|
||||||
|
j["orderedItems"] = []junk.Junk{}
|
||||||
|
|
||||||
|
return j.ToBytes(), true
|
||||||
|
}})
|
||||||
|
|
||||||
func emptiness(w http.ResponseWriter, r *http.Request) {
|
func emptiness(w http.ResponseWriter, r *http.Request) {
|
||||||
name := mux.Vars(r)["name"]
|
name := mux.Vars(r)["name"]
|
||||||
user, err := butwhatabout(name)
|
user, err := butwhatabout(name)
|
||||||
|
@ -662,20 +679,14 @@ func emptiness(w http.ResponseWriter, r *http.Request) {
|
||||||
http.NotFound(w, r)
|
http.NotFound(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
colname := "/followers"
|
var j []byte
|
||||||
if strings.HasSuffix(r.URL.Path, "/following") {
|
ok := oldempties.Get(r.URL.Path, &j)
|
||||||
colname = "/following"
|
if ok {
|
||||||
}
|
|
||||||
j := junk.New()
|
|
||||||
j["@context"] = itiswhatitis
|
|
||||||
j["id"] = user.URL + colname
|
|
||||||
j["attributedTo"] = user.URL
|
|
||||||
j["type"] = "OrderedCollection"
|
|
||||||
j["totalItems"] = 0
|
|
||||||
j["orderedItems"] = []junk.Junk{}
|
|
||||||
|
|
||||||
w.Header().Set("Content-Type", theonetruename)
|
w.Header().Set("Content-Type", theonetruename)
|
||||||
j.Write(w)
|
w.Write(j)
|
||||||
|
} else {
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func showuser(w http.ResponseWriter, r *http.Request) {
|
func showuser(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
Loading…
Reference in New Issue