diff options
author | Romuald Brillout <github@brillout.com> | 2021-01-15 18:38:13 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2021-01-25 19:46:04 +0300 |
commit | 63d978c5c14a54bb8546c5aa7a8fd8c94a8744c2 (patch) | |
tree | aa57dd47cee5dc8b4a640c488d1153549b979f69 /doc/api/async_hooks.md | |
parent | 7394311a2eba15270c34835da31973e1e5ab02db (diff) |
doc: improve AsyncLocalStorage introduction
PR-URL: https://github.com/nodejs/node/pull/36946
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'doc/api/async_hooks.md')
-rw-r--r-- | doc/api/async_hooks.md | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/doc/api/async_hooks.md b/doc/api/async_hooks.md index 4a8a225c576..5f1d578beeb 100644 --- a/doc/api/async_hooks.md +++ b/doc/api/async_hooks.md @@ -973,6 +973,11 @@ chains. It allows storing data throughout the lifetime of a web request or any other asynchronous duration. It is similar to thread-local storage in other languages. +While you can create your own implementation on top of the `async_hooks` module, +`AsyncLocalStorage` should be preferred as it is a performant and memory safe +implementation that involves significant optimizations that are non-obvious to +implement. + The following example uses `AsyncLocalStorage` to build a simple logger that assigns IDs to incoming HTTP requests and includes them in messages logged within each request. |