ehcache.xml配置详解
1. 在Hibernate配置文件中设置:
<!--HibernateSessionFactory-->
<beanid="sessionFactoryclassorg.springframework.orm.hibernate3.LocalSessionFactoryBean> propertynamedataSourceref/> mappingResourceslistvalue>com/ououmodelVideos.hbm.xml</> propertyhibernatePropertiespropspropkeyhibernate.dialectorg.hibernate.dialect.MySQLDialectprophibernate.current_session_context_classthreadhibernate.cglib.use_reflection_optimizerfalsehibernate.query.substitutionstrue'Y,Naddehcachehibernate.cache.provider_classorg.hibernate.cache.EhCacheProviderhibernate.cache.use_query_cache><!--是否使用查询缓存 <!-- hibernate.cache.provider_configuration_file_resource_path>/ehcache.xmlhibernate.show_sql--> <!--<hibernate.transaction.auto_close_session>--> connection.provider_classorg.hibernate.connection.C3P0ConnectionProviderCreate/ updatethedatabasetablesautomaticallywhentheJVMstartsup hibernate.hbm2ddl.autoupdateTurnbatchingoffforbettererrormessagesunderPostgreSQLhibernate.jdbc.batch_size25hibernate.connection.pool_size10bean>
ehcache
<!-- Setsthepathtothedirectorywherecache.datafilesarecreated. IfthepathisaJavaSystemPropertyitisreplacedby itsvalueintherunningVM. Thefollowingpropertiesaretranslated: user.home-Usershomedirectory user.dirscurrentworkingdirectory java.io.tmpdirDefaulttempfilepathdiskStorepath/>--> /data/ehcacheDefaultCacheconfiguration.Thesewillappliedtocachesprogrammaticallycreatedthrough theCacheManager. Thefollowingattributesarerequired: maxElementsInMemory- Setsthemaximumnumberofobjectsthatwillbecreatedinmemory eternalSetswhetherelementsareeternal.Ifeternal,timeoutsare ignoredandtheelementisneverexpired. overflowToDiskSetswhetherelementscanoverflowtodiskwhentheinmemorycache hasreachedthemaxInMemorylimit. Thefollowingattributesareoptional: timeToIdleSecondsSetsthetimetoidlefor anelementbeforeitexpires. i.e.Themaximumamountoftimebetweenaccessesbeforean elementexpiresIsonlyusedif theelementisnoteternal. Optionalattribute.Avalueof0 meansthatanElementcanidle infinity.Thedefaultvalueis. timeToLiveSecondsSetsthetimetoliveanelementbeforeitexpires. i.e.Themaximumtimebetweencreationtimeandwhenanelement expires.IsonlyusedmeansthatandElementcanlive infinity. The. diskPersistentWhetherthediskstorepersistsbetweenrestartsoftheVirtual Machine. Thefalse . diskExpiryThreadIntervalSecondsThenumberofsecondsbetweenrunsofthediskexpirythread. The120 seconds. < defaultCache maxElementsInMemory10000" eternal false overflowToDisk true timeToIdleSeconds 120 timeToLiveSeconds diskPersistent diskExpiryThreadIntervalSeconds cachenameorg.hibernate.cache.UpdateTimestampsCachemaxElementsInMemory5000" eternaloverflowToDiskorg.hibernate.cache.StandardQueryCache5eternaluserCache100000timeToIdleSeconds= " 600 timeToLiveSecondsdiskPersistentcom.ouou.webapp.util.OuouMethodInteceptertimeToLiveSecondsbbcode overflowToDiskcom.ouou.model.Videoscom.ouou.model.Tags>
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |