Ole*_*ndr 5 grails hibernate ehcache
什么是Hibernate\Grails中最好的缓存策略.是否缓存所有实体和查询以及如何找到最佳解决方案?
这是我的hibernate配置.
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.provider_class = 'org.hibernate.cache.EhCacheProvider'
connection.useUnicode = true
connection.characterEncoding = 'UTF-8'
connection.provider_class = 'org.hibernate.connection.C3P0ConnectionProvider'
dialect = 'org.hibernate.dialect.MySQL5InnoDBDialect'
order_updates = true
c3p0.min_size = 5
c3p0.max_size = 20
c3p0.max_statements = 20 * 10
c3p0.idle_test_period = 15 * 60
}
Run Code Online (Sandbox Code Playgroud)
Ehcache配置
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
maxElementsOnDisk="10000000"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
diskSpoolBufferSizeMB="100"
memoryStoreEvictionPolicy="LRU"
/>
<cache
name="org.hibernate.cache.StandardQueryCache"
maxElementsInMemory="50"
eternal="false"
timeToLiveSeconds="120"
overflowToDisk="true"
/>
Run Code Online (Sandbox Code Playgroud)
jpk*_*ing 12
最好的缓存策略是:不缓存.说真的,应该只进行缓存(和任何优化)以解决现有问题.如果您没有性能问题,请不要使用缓存.如果确实存在性能问题,请应用这个简单的5步过程来解决性能问题:
请注意,如果您不了解缓存在Hibernate中的工作方式,那么最终可能会导致性能不佳,而不是改进它.此外,即使您了解缓存如何在Hibernate中工作,也可能存在影响性能的其他影响,导致数据库往返速度比查找缓存更快.这就是为什么你应该在做"改进"之前和之后进行衡量.
归档时间: |
|
查看次数: |
2420 次 |
最近记录: |