Java – hibernate cache using ehcache cluster: nonstrict for strict read and write

What is the real difference between unrestricted reading and writing and reading and writing? I can read ehcache and Hibernate documents, but as far as I can see, they will only say "if you update, reading and writing will be better" I don't feel well

I may have a problem with a long-term stored cache collection. The configuration is as follows:

<cache name="trx.domain.Parent.children" maxElementsInMemory="5000"
    eternal="false" overflowToDisk="false" timeToIdleSeconds="1200"
    timeToLiveSeconds="1800">
    <cacheEventListenerFactory
        class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
        properties="replicateAsynchronously=true,replicatePuts=true,replicateUpdates=true,replicateUpdatesViaCopy=false,replicateRemovals=true" />@H_502_5@ 
  
  
 
<set name="children" lazy="false" inverse="true">
    <cache usage="nonstrict-read-write"/>
    <key column="callout_id" />
    <one-to-many class="Child" />
</set>@H_502_5@ 
 

当更新集合,在发生更新的节点和其他节点上,究竟发生了什么?这里的非限制性读写和读写有什么区别?一个节点有可能使用其从缓存中过去的10分钟版本吗?

请注意冗长的超时和异步复制.

Solution

Read / write: if two transactions attempt to modify data, these transactions are isolated at the "committed" level (or repeatable read if the database is set to this) - usually this is sufficient, and usually we don't need the "serializable" isolation level

Nonstrict read / write: the cache is not locked, so if two transactions modify data, we don't know what we get. We don't guarantee cache state = database state

Only data is unlikely to be modified by two transactions at the same time, which is safe We also need to set the appropriate cache timeout

For more details and very good explanations, please see here: Hibernate cache strategy

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>