有什么好处?"/>
使用nodejs AsyncLocalStorage有什么好处?
不明白使用AsyncLocalStorage的目的。
例如:
const store = { id: 1 };
// Replaces previous store with the given store object
asyncLocalStorage.enterWith(store);
asyncLocalStorage.getStore(); // Returns the store object
someAsyncOperation(() => {
asyncLocalStorage.getStore(); // Returns the same object
});
为什么我们只使用普通的 javascript 而不是它?
let store;
export const getStore = () => store;
export const setStore = (value) => {
store = value;
};
回答如下:
更多推荐
使用nodejs AsyncLocalStorage有什么好处?
发布评论