MCPcopy Create free account
hub / github.com/gorilla/context / Purge

Function Purge

context.go:112–130  ·  view source on GitHub ↗

Purge removes request data stored for longer than maxAge, in seconds. It returns the amount of requests removed. If maxAge <= 0, all request data is removed. This is only used for sanity check: in case context cleaning was not properly set some request data can be kept forever, consuming an increa

(maxAge int)

Source from the content-addressed store, hash-verified

110// amount of memory. In case this is detected, Purge() must be called
111// periodically until the problem is fixed.
112func Purge(maxAge int) int {
113 mutex.Lock()
114 count := 0
115 if maxAge <= 0 {
116 count = len(data)
117 data = make(map[*http.Request]map[interface{}]interface{})
118 datat = make(map[*http.Request]int64)
119 } else {
120 min := time.Now().Unix() - int64(maxAge)
121 for r := range data {
122 if datat[r] < min {
123 clear(r)
124 count++
125 }
126 }
127 }
128 mutex.Unlock()
129 return count
130}
131
132// ClearHandler wraps an http.Handler and clears request values at the end
133// of a request lifetime.

Callers

nothing calls this directly

Calls 1

clearFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…