(encoding string, r *http.Request)
| 259 | } |
| 260 | |
| 261 | func (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 | |
| 281 | func (c *Compressor) compress(ctx context.Context, encoding string, cref ref, r *http.Request) { |
| 282 | cachePath := cref.key.filePath(c.cacheDir) |
no test coverage detected