MCPcopy Index your code
hub / github.com/coder/coder / getRef

Method getRef

coderd/cachecompress/compress.go:261–279  ·  view source on GitHub ↗
(encoding string, r *http.Request)

Source from the content-addressed store, hash-verified

259}
260
261func (c *Compressor) getRef(encoding string, r *http.Request) ref {
262 ck := getCacheKey(encoding, r)
263 c.mu.Lock()
264 defer c.mu.Unlock()
265 cref, ok := c.cache[ck]
266 if ok {
267 return cref
268 }
269 // we are the first to encode
270 cref = ref{
271 key: ck,
272
273 done: make(chan struct{}),
274 err: make(chan error),
275 }
276 c.cache[ck] = cref
277 go c.compress(context.Background(), encoding, cref, r)
278 return cref
279}
280
281func (c *Compressor) compress(ctx context.Context, encoding string, cref ref, r *http.Request) {
282 cachePath := cref.key.filePath(c.cacheDir)

Callers 1

ServeHTTPMethod · 0.95

Calls 4

compressMethod · 0.95
getCacheKeyFunction · 0.85
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected