6
當我打電話給UserManager.FindByIdAsync(User.Identity.GetUserId())
時,它會緩存,還是每次調用數據庫時都調用它?UserManager.FindByIdAsync(User.Identity.GetUserId())緩存嗎?
當我打電話給UserManager.FindByIdAsync(User.Identity.GetUserId())
時,它會緩存,還是每次調用數據庫時都調用它?UserManager.FindByIdAsync(User.Identity.GetUserId())緩存嗎?
它不會緩存,底層store/dbcontext可能會緩存,但管理器本身沒有緩存,它總是調用到UserStore。
我99%確定它不緩存。如果你想緩存,可以在你的數據庫層設置緩存或者從HttpContext緩存中存儲槓桿。 – Tommy
謝謝@湯米,我認爲這將是答案...;) – Chaddeus
沒問題 - 我會作爲答覆發佈,但我找不到任何明確(MSDN等)來支持我的說法。 – Tommy