Use write lock
This commit is contained in:
parent
892dde64aa
commit
4c0f77e806
1 changed files with 6 additions and 2 deletions
|
@ -109,8 +109,12 @@ class ResponseCache {
|
|||
}
|
||||
|
||||
// Save the response.
|
||||
_cache[req.uri.path] = new _CachedResponse(
|
||||
new Map.from(res.headers), res.buffer.toBytes(), now);
|
||||
var writeLock = _writeLocks.putIfAbsent(req.uri.path, () => new Pool(1));
|
||||
await writeLock.withResource(() {
|
||||
_cache[req.uri.path] = new _CachedResponse(
|
||||
new Map.from(res.headers), res.buffer.toBytes(), now);
|
||||
});
|
||||
|
||||
_setCachedHeaders(now, req, res);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue