2010-01-07 4 views
2

저는 며칠 동안이 일을 해왔습니다. 나는 Memcached 서버와 NHContrib의 공급자와 함께 두 번째 수준의 캐시를 사용하도록 내 웹/앱 구성을 구성했습니다. 나는 아직 테스트에서 예외를 얻지는 않는다. cacheable = true를 설정 한 쿼리에 대해 캐시를 사용하지 않는다는 것을 알 수있다. 공급자를 NHibernate.Cache.HashtableCacheProvider로 전환하고 테스트가 예상대로 작동하는지 확인하십시오. 여기 Memcached NHibernate 제공자가 작동하지 않습니다.

내가 만료 속성을 다른 사람 (SysCache)

같은 공급자 구성에 세션 공장 수준에서 memcache에 공급자에 대한 설정 안된다고 생각 나는
<configuration> 
    <configSections> 
    <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler,NHibernate" /> 
    <section name="memcache" type="NHibernate.Caches.MemCache.MemCacheSectionHandler,NHibernate.Caches.MemCache" /> 
    </configSections> 
    <memcache> 
    <memcached host="192.168.215.60" port="11211" /> 
    </memcache> 

    <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> 
    <session-factory> 
     <property name="connection.provider"> 
     NHibernate.Connection.DriverConnectionProvider 
     </property> 
     <property name="dialect"> 
     MT.Core.Persistence.Dialect, MT.Core 
     </property> 
     <property name="connection.driver_class"> 
     NHibernate.Driver.SqlClientDriver 
     </property> 
     <property name="connection.connection_string"> 
     Server=192.168.1.1;Initial Catalog=Test;User ID=TestUser;Password=fakepassword; 
     </property> 
     <property name="show_sql">true</property> 
     <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory,NHibernate.ByteCode.LinFu</property> 
     <property name="cache.provider_class">NHibernate.Caches.MemCache.MemCacheProvider,NHibernate.Caches.MemCache</property> 
     <!--<property name="cache.provider_class">NHibernate.Cache.HashtableCacheProvider</property>--> 
     <property name="cache.use_second_level_cache">true</property> 
     <property name="cache.use_query_cache">true</property> 
    </session-factory> 

    </hibernate-configuration> 
</configuration> 

답변

0

을 사용하고 관련 설정 부분입니다
<property name="expiration">300</property> 
+0

cache.default_expiration에 대한 세션 팩토리 아래에 속성이 있지만 이것을 추가해도 캐시가 작동하지 않습니다. 나는 여전히 데이터베이스에서 두 개의 쿼리를 볼 수있는 테스트를 볼 수 있습니다. – CountCet

+0

나는 memcache를 사용하기 때문에 만료를 시도했는데 그것이 나를 위해 일하고있다. – MatthieuGD

+0

예 정확한 속성을 추가했는데 예외가 발생하고 예외가 발생했습니다. 나는 Nhibernate 2.1.2에 있습니다. – CountCet

2

문제는 연결 문제로 종료되었습니다. log4net을 사용하여 콘솔과 응용 프로그램 로그에 오류를 기록했습니다. Memcached 서버에 연결하는 것과 관련된 오류를 마침내 보았습니다. 코드가 동일한 위치의 서버로 승격되면 오류가 사라집니다. 나는 전에 log4net 시대를 사용하는 법을 배웠어야했다.

2

memcache의 경우 'default_expiration'속성은 '만료'가 아닙니다. SysCache에 대해 잘 모르겠습니다. 하지만 저는이 속성을 memcache에 사용했으며 저에게 효과적입니다.

처음에는 CountCet이 언급 한 것과 동일한 오류가 발생했습니다. '만료'특성이 MemCache 공급자에 의해 인식되지 않습니다. 나중에 코드를 검사하여 'default_expiration'속성을 사용하고 기본값은 300 초입니다.

관련 문제