Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

EntityCache repository thread safety #7084


User avatar
0
antonis created

Hi,

EntityCache is a singleton class. I saw the code of abp and noticed that a IRepository is injected into EntityCache. Since entitycache is singleton and dependency is scoped these would lead to captive dependency and even worse the same repository instance will be used by whatever other service is registered as singleton and uses that repository. Eventually this would cause bigger problems since dbcontext is not thread safe.

Can you advise?

Thanks


3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    EntityCache is not a singleton, right?

    https://aspnetboilerplate.com/Pages/Documents/Caching#entity-caching

  • User Avatar
    0
    antonis created

    If it is a transient how it is caching then since every request has its own PersonCache?

  • User Avatar
    1
    maliming created
    Support Team

    Because the ICacheManager used internally is a singleton.