java - hibernate cached query not updated when new record inserted -
we have ehcache cluster, hibernate , mysql.
everything working fine. criteria searches being cached , when records modified on other members of clusters cached queries updated instantly on other servers.
however, problem when new records inserted. cached queries on table not know until cached query expired.
i have missed on ehcache.xml configuration, have no idea be.
any ideas?
ehcache.xml follows:
`
<!--<diskstore path="java.io.tmpdir"/>--> <!-- means cache replication --> <cachemanagerpeerproviderfactory class="net.sf.ehcache.distribution.jgroups.jgroupscachemanagerpeerproviderfactory" properties="connect= tcp(bind_port=10700): s3_ping(...): merge2(max_interval=30000;min_interval=10000): fd_sock(start_port=0): fd(timeout=3000;max_tries=3): verify_suspect(timeout=1500): barrier(): pbcast.nakack(use_mcast_xmit=false;gc_lag=0;retransmit_timeout=300,600,1200,2400,4800;discard_delivered_msgs=true): unicast(timeout=300,600,1200): pbcast.stable(stability_delay=1000;desired_avg_gossip=50000;max_bytes=400k): pbcast.gms(print_local_addr=true;join_timeout=300;view_bundling=true): fc(max_credits=2m;min_threshold=0.10): frag2(frag_size=60k): pbcast.streaming_state_transfer()" propertyseparator="::" /> <!-- default query cache used queries without explicit cache --> <cache name="org.hibernate.cache.standardquerycache" maxelementsinmemory="100" eternal="false" timetoliveseconds="600" overflowtodisk="false" statistics="true"> <cacheeventlistenerfactory class="net.sf.ehcache.distribution.jgroups.jgroupscachereplicatorfactory" properties="replicateasynchronously=true, replicateputs=true, replicateupdates=true, replicateupdatesviacopy=false, replicateremovals=true" /> </cache> <!-- timestamps of particular last update time tables --> <cache name="org.hibernate.cache.updatetimestampscache" maxelementsinmemory="5000" eternal="true" overflowtodisk="false" statistics="true"> <cacheeventlistenerfactory class="net.sf.ehcache.distribution.jgroups.jgroupscachereplicatorfactory" properties="replicateasynchronously=true, replicateputs=true, replicateupdates=true, replicateupdatesviacopy=false, replicateremovals=true" /> </cache> <!-- default cache use cacheable entities without explicit cache --> <defaultcache maxelementsinmemory="10000" eternal="false" timetoidleseconds="600" timetoliveseconds="600" overflowtodisk="false" maxelementsondisk="10000000" diskpersistent="false" diskexpirythreadintervalseconds="600" memorystoreevictionpolicy="lru" statistics="true"> <cacheeventlistenerfactory class="net.sf.ehcache.distribution.jgroups.jgroupscachereplicatorfactory" properties="replicateasynchronously=true, replicateputs=true, replicateupdates=true, replicateupdatesviacopy=false, replicateremovals=true" /> </defaultcache>
`
i'm afraid it's little late author, thought answer can useful else same problem.
you should remember how standardquerycache
, updatetimestampscache
work. when query cache checked query, time query cached compared timestamps of last update of tables in query. if tables updated after query cached, cached result gets discarded , database used instead. timestamps of last update each table stored in updatetimestampscache
.
in above configuration values updatetimestampscache
not copied other members of cluster, hibernate looks @ old timestamps , thinks cached query up-to-date. result newly inserted records neglected. fix set replicateupdatesviacopy
updatetimestampscache
true.
Comments
Post a Comment