最近學(xué)緩存,我配置好像都通過編譯,而且已經(jīng)成功運(yùn)行,但是我調(diào)試的時候,發(fā)現(xiàn)ISessionFactory對象里面沒有我已經(jīng)配置好的緩存,配置如下:
config里面的:
?<property name="cache.provider_class">NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache</property>????? ????? <property name ="cache.use_second_level_cache">true</property>????? <property name="cache.use_query_cache">true</property>
hmb文件里面的:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"? assembly="Test" namespace="Test">? <class name="Test.Person,Test" table="person" >??? <cache usage="read-write"/>??? <id name="Id" column="id" type="string" >??? </id>??? ??? <property name="PerName" column ="perName" type="string" length="30" not-null="true"/>??? <property name ="Password" column="password" type="string" length="30" not-null="true"/>??? ??? <set name="ListMessage" table="MessageContext" cascade="all" >????? <cache usage="read-write"/>????? <key column="idPerson" not-null="true"/>????? <one-to-many class="Test.messageContext,Test"/>??? </set>??? <one-to-one? name="Message"? class="Test.NewsMessage,Test" cascade="all"/>? </class>? </hibernate-mapping>
調(diào)試的時候只能在Statistics.SecondLevelCacheRegionNames屬性里面看到名字,沒發(fā)現(xiàn)有數(shù)據(jù)存入。
然后我有使用了查詢緩存:
?IQuery qury = session.CreateQuery("from Person where Id =:idin").SetCacheable(true);??????????? qury.SetParameter("idin", this.txtUserID.Text);
調(diào)試,結(jié)果這個查詢緩存在Statistics.SecondLevelCacheRegionNames里根本就沒有。
Nhibernate二級緩存
揚(yáng)帆大魚
2018-12-06 16:00:39