Note that there are some explanatory texts on larger screens.

plurals
  1. POLINQ driven cache items invalidation
    text
    copied!<p>I'm making an ASP.NET MVC project and i would like to implement business data caching at repository (LINQ2SQL) layer. Since entities are related to each other, i need to invalidate related ones when i'm invalidating some base entity. Say i have Blog/Post/Comments relation and when user makes a new comment then i need to invalidate cached Post entity since it has outdated TotalComments field. Sometimes there is as more complicated logic for invalidation other entities.<br> Well, i need to implement flexible invalidation mechanism for that purpose. What i've found before:<br> - SQL notifications service. It notifies the app each time table has changed. Since i'll have high-loaded application, changes on some tables gonna be very often. All cached comments to any post will drop each time a new comment is added.<br> - Caching LINQ(or SQL) queries. In this case the rendered query is placed to the cache using its hash as a key. Not bad but it will be impossible to drop "all comment entities having BlogPostId = deletedBlogPostId" </p> <p>And now what my idea is. I wanna use LINQ queries over HttpRuntime.Cache items to find items to be deleted by their properties (e.g. in case of deleting a blog post i look for </p> <pre><code>cachedItem =&gt; cachedItem.GetType() == typeof(Comment) &amp;&amp; ((Comment)cachedItem).BlogPostId == deletedBlogPostId </code></pre> <p>to delete all related comments). But i can't find in google this approach is widely used. Isn't it a good way to manipulate with cached related entities? Query performance over 1M cached items is 600 ms on my notebook.<br> Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload