asyncLocalStorage.disable()
¥Stability: 1 - Experimental
禁用 AsyncLocalStorage
的实例。对 asyncLocalStorage.getStore()
的所有后续调用都将返回 undefined
,直到再次调用 asyncLocalStorage.run()
或 asyncLocalStorage.enterWith()
。
¥Disables the instance of AsyncLocalStorage
. All subsequent calls
to asyncLocalStorage.getStore()
will return undefined
until
asyncLocalStorage.run()
or asyncLocalStorage.enterWith()
is called again.
调用 asyncLocalStorage.disable()
时,将退出所有当前链接到该实例的上下文。
¥When calling asyncLocalStorage.disable()
, all current contexts linked to the
instance will be exited.
在可以对 asyncLocalStorage
进行垃圾回收之前,需要调用 asyncLocalStorage.disable()
。这不适用于 asyncLocalStorage
提供的存储,因为这些对象与相应的异步资源一起被垃圾回收。
¥Calling asyncLocalStorage.disable()
is required before the
asyncLocalStorage
can be garbage collected. This does not apply to stores
provided by the asyncLocalStorage
, as those objects are garbage collected
along with the corresponding async resources.
当 asyncLocalStorage
在当前进程中不再使用时使用此方法。
¥Use this method when the asyncLocalStorage
is not in use anymore
in the current process.