Base solution for your next web application
Open Closed

Domain Layer Cache #9162


User avatar
0
fawad29 created

I have a permission checking code in application service and I would like to move it to the domain service as it is being used by more than one application services. In the current method, I get the permissions from the database and has implemented a cache so that the next time application does not get the permissions from the database. My question is that you recommend implementing cache in application service so if I move this method to the domain service then I will lose the functionality of cache. I can see following three options, can you help?

  1. I create a method in the domain service that simply calls this existing application service method (this way cache is already implemented in the application service), all application services call this new domain service function.
  2. Implement the method in the domain service and implement cache in the domain service (I don't know if it can be done in ABP architecture).
  3. Implment the method in the domain service with cache (this is NOT ideal).

5 Answer(s)
  • User Avatar
    0
    musa.demir created

    Hi @learner29

    If you use IPermissionChecker, it already has cache implementation. You can just use it anywhere you want. Is it what you use to check permission?

  • User Avatar
    0
    fawad29 created

    Permission Checker is just an example, it could be something completely different as well, so what would be the best way for that. Please provide some example with code.

    1. I create a method in the domain service that simply calls this existing application service method (this way cache is already implemented in the application service), all application services call this new domain service function.
    2. Implement the method in the domain service and implement cache in the domain service (I don't know if it can be done in ABP architecture).
    3. Implment the method in the domain service with cache (this is NOT ideal).
  • User Avatar
    0
    ismcagdas created
    Support Team
  • User Avatar
    0
    fawad29 created

    So, are you saying that I use item 2 from the list given below? If I use 1 from the list below, will it have any issues?

    1. I create a method in the domain service that simply calls this existing application service method (this way cache is already implemented in the application service), all application services call this new domain service function.
    2. Implement the method in the domain service and implement cache in the domain service (I don't know if it can be done in ABP architecture).
    3. Implment the method in the domain service with cache (this is NOT ideal)
  • User Avatar
    0
    musa.demir created

    Yes @leaner29, you can use cache manager in domain service just like @ismcagdas said. So

    2 .Implement the method in the domain service and implement cache in the domain service

    seems good.