MCPcopy Create free account
hub / github.com/allegro/bigcache / getCacheHandler

Function getCacheHandler

server/cache_handlers.go:24–45  ·  view source on GitHub ↗

handles get requests.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

22
23// handles get requests.
24func getCacheHandler(w http.ResponseWriter, r *http.Request) {
25 target := r.URL.Path[len(cachePath):]
26 if target == "" {
27 w.WriteHeader(http.StatusBadRequest)
28 w.Write([]byte("can't get a key if there is no key."))
29 log.Print("empty request.")
30 return
31 }
32 entry, err := cache.Get(target)
33 if err != nil {
34 errMsg := (err).Error()
35 if strings.Contains(errMsg, "not found") {
36 log.Print(err)
37 w.WriteHeader(http.StatusNotFound)
38 return
39 }
40 log.Print(err)
41 w.WriteHeader(http.StatusInternalServerError)
42 return
43 }
44 w.Write(entry)
45}
46
47func putCacheHandler(w http.ResponseWriter, r *http.Request) {
48 target := r.URL.Path[len(cachePath):]

Callers 4

cacheIndexHandlerFunction · 0.85
TestGetWithNoKeyFunction · 0.85
TestGetWithMissingKeyFunction · 0.85
TestGetKeyFunction · 0.85

Calls 2

GetMethod · 0.45
ErrorMethod · 0.45

Tested by 3

TestGetWithNoKeyFunction · 0.68
TestGetWithMissingKeyFunction · 0.68
TestGetKeyFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…