I wan't to manually invalidate (refresh) the 2nd level cache. How can I do that?
Asked
Active
Viewed 1,398 times
4
-
1Duplicate: http://stackoverflow.com/questions/2985749/nhibernate-second-level-cache-with-external-updates – cbp Apr 07 '11 at 02:11
-
possible duplicate of [How to clear the entire second level cache in NHibernate](http://stackoverflow.com/questions/2660714/how-to-clear-the-entire-second-level-cache-in-nhibernate) – Diego Mijelshon Apr 07 '11 at 13:33
1 Answers
5
You can do something like this:
SessionFactory.EvictQueries();
foreach (var collectionMetadata in this._SessionFactory.GetAllCollectionMetadata())
SessionFactory.EvictCollection(collectionMetadata.Key);
foreach (var classMetadata in this._SessionFactory.GetAllClassMetadata())
SessionFactory.EvictEntity(classMetadata.Key);

LeftyX
- 35,328
- 21
- 132
- 193
-
Yes, and I love it :-) Actually, I knew I had got it from someone but I didn't remember it was your. – LeftyX Apr 07 '11 at 16:59