About a week ago I published on NuGet the Alpha-2 version of the EFCache. It does not contain a whole lot of new things. In fact it contains just one change – a fix to a bug which prevented from using the cache with databases containing null values. This bug was reported by multiple people and was quite easy to hit since having null values in the database is a very common scenario. The best part of the story is that I actually did not code the fix myself. The fix was kindly contributed by Teoni Valois. Teoni also created an EFCache implementation called DacheCache which uses Dache – a distribute cache for .NET – as the caching mechanisms. You can get DachCache from NuGet.
Again, thanks for the contribution and reporting issues (yes, the version for .NET Framework 4 will be included in the upcoming Beta release). If you hit the bug and gave up on using EFCache give the Alpha-2 a try.
Hello,
Is this cache universal? I mean, does it cache everything or we can say this specific query should be cacheable and this one should not. For example NHibernate has `Cacheable()` method for second level caching (session.Query().Cacheable().ToList()). I need session.Query().ToList() for private parts of the site and session.Query().Cacheable().ToList() for public parts of the site.
LikeLike
Hi Ali,
You can control what gets cached by implementing a custom caching policy. You just create a class derived from the CachingPolicy class and pass an instance of your custom caching policy when creating the CachingProviderSrevices. A default caching policy which allows caching everything is included (see this post for more details). Currently however the caching policy does not allow to control caching based on specific queries. Instead it is using a concept of a store entity set (from the caching perspective it is just a fancy way of saying “table”). You can also decide whether to cache results depending on the size. I don’t know NHibernate but caching based on a specific query (and, possibly, parameters) is an interesting option. I will add it to my backlog.
Thanks,
Pawel
LikeLike
moozzyk, it was supported in my initial implementation. Maybe it could help?
LikeLike
https://github.com/loresoft/EntityFramework.Extended project has `Query Result Cache` mechanism with `FromCache()` extension method.
LikeLike
It was implemented in my original pull request. Maybe it could help?
LikeLike
Yes, but architecturally this cannot be done solely in the caching policy/caching mechanisms. I believe this needs to be driven by the EFCache which will make the solution much cleaner and will allow to avoid hacks. I added more details on this to the workitem on codeplex.
Thanks,
Pawel
LikeLike