How to clear the entire second level cache in NHibernate

I wish to clear the entire second level cache in NHibernate via code. Is there a way to do this which is independent of the cache provider being used? (we have customers using both memcache and syscache within the same application).

We wish to clear the entire cache because of changes external to the database may have occurred (and we have no guarantees re: which tables/entities were affected, so we have to assume the worst).


这应该做到:

sessionFactory.EvictQueries();
foreach (var collectionMetadata in sessionFactory.GetAllCollectionMetadata())
         sessionFactory.EvictCollection(collectionMetadata.Key);
foreach (var classMetadata in sessionFactory.GetAllClassMetadata())
         sessionFactory.EvictEntity(classMetadata.Key);
链接地址: http://www.djcxy.com/p/71046.html

上一篇: NHibernate.MappingException:没有persister:XYZ

下一篇: 如何清除NHibernate中的整个二级缓存