【发布时间】:2011-06-23 21:44:31
【问题描述】:
我正在尝试使用 Ehcache 后写缓存将批量事务写入我的数据库。我需要的是后写缓存以 5 秒间隔(或更频繁)转储事务。
我一定是遗漏了一些东西,因为尽我所能,它就是行不通。我设置了后写缓存,然后将负载放到服务器上。几千,再后来几十万的交易,等了几分钟,数据库里还是什么都没有。直到我关闭服务器上的负载,缓存才开始写入数据库。
这是线程优先级的问题吗?有没有办法修改 Ehcache 以在服务器负载下执行 DB 写入?
这是我的配置:
<cache name="server.db.model.Request"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="5"
timeToLiveSeconds="5"
overflowToDisk="false"
memoryStoreEvictionPolicy="FIFO">
<cacheWriter writeMode="write_behind" maxWriteDelay="5" rateLimitPerSecond="5"
writeCoalescing="true" writeBatching="true" writeBatchSize="5000"
retryAttempts="2" retryAttemptDelaySeconds="10">
<cacheWriterFactory class="server.db.util.RequestCacheWriterFactory"/>
</cacheWriter>
</cache>
谢谢。
【问题讨论】: