Similar Posts

Leave a Reply

Your email address will not be published.

16 Comments

  1. Thanks, Mukesh

    What about Entity Framework Core 3.1.x Second Level Caching Library. Is that something different?

    1. Hi, The aim is quite the same with EFCORE Second Level Cache Interceptor. The only difference is that the library is exclusively built for EFCore and IMemorycache is a general purpose caching interface. That is, it can cache not only query data of efcore, but also other stuffs like views, images, configurations etc

      Regards

      1. So if we use IMemorycache It would cover second level cache and we no longer need to use EFCORE Second Level Cache Interceptor. Is that right?

  2. Hi, Mukesh how we can define a caching technique with no expiration(The cache will not clear untill the application restart) ?

    1. Hi Sarath, You can probably check the ENUM, CacheItemPriority and set it to CacheItemPriority.NeverRemove. This will prevent cache removal due to memory pressures. Other ways are to 1. Set a longer Absolute Expiration period. 2. Set a CallBack Method on Cache Expiration and re-set the cache key again.

      Regards

  3. Hi Mukesh, with example above about get list customers. When I insert new customer in Db. Client call api get list customers, is data refreshed or not?

    1. Hi,
      With the current setup, NO the data wont be refreshed. It would be refreshed only when the cache is expired and new cache is set. What usually happens is that, at every Insert / Modification, you will have to call the caching service again again re-fill the cache so that it is updated at every change. Alternatively you could use a Background Job Invoker like Hangfire to re-cache at a particular time interval regularly. This will improve the UX of the application.

      Regards.

  4. Hi Mukesh, how we can cache a list with search conditions like search by name, age,… Should I cache this list with the key which is hashed from search condition ?

  5. Hi; I have been struggling getting the expirationtoken working; it never seems to fire … could you extend your article to cover this facility please.