If you want to use a Provider impl, have a look at TreeCacheProviderHook and
OptimisticTreeCacheProviderHook in the AS trunk ejb3 module, org.jboss,ejb3.entity
package. Those are based on AS 4.2.0 classes that have some bug fixes in them that
aren't in the Hibernate classes, particularly related to classloading issues. In AS
trunk I converted them to the JBC 2.0 API. Those classes will be replaced by the new
Hibernate stuff, and may have bugs, but they may save you some work.
It's been a while, but IIRC, the biggest problem with the trunk classes is timestamp
caching doesn't work properly -- the JBC 2.0 putForExternalRead semantic won't
work for timestamps. Timestamps need to be replicated async, so you'd need to use
Option.setForceAsynchronous(true) (only in 2.1.0) to make that happen if the cache region
is for the timestamps cache.
Another caveat is INVALIDATION shouldn't be used if query caching is enabled.
INVALIDATION_SYNC is the best choice for entity/collection caching but is absolutely
incorrect for timestamp caching. Hence the move to using different multiplexed JBC
instances.
Re: eviction, let's say you've given a region prefix to your session factory of
"foo" and are caching an entity of type com.foo.Bar. Query caching is enabled.
With a Provider, you'd end up with these regions in JBC:
/foo/com/foo/Bar
/foo/org/hibernate/cache/StandardQueryCache
/foo/org/hibernate/cache/UpdateTimestampsCache
Typically you'd set up an LRU eviction region config for /foo/com/foo/Bar and probably
another for /foo/org/hibernate/cache/StandardQueryCache. What the maxNodes,
timeToLiveSeconds etc should be would depend on... well the normal stuff. :-)
You should never set up an eviction region that results in eviction of data under
/foo/org/hibernate/cache/UpdateTimestampsCache. This precludes just setting up a region
for /foo or just using /_default_ when you are using query caching.
With the new RegionFactory approach, you'd have these JBC regions:
/foo/com/foo/Bar/ENTITY
/foo/com/foo/Bar/COLL
/foo/org/hibernate/cache/StandardQueryCache
/TS/foo/org/hibernate/cache/UpdateTimestampsCache
Typically you'd set up an LRU eviction region config for /foo/com/foo/Bar and probably
another for /foo/org/hibernate/cache/StandardQueryCache -- exactly the same as with
Provider. The existence of the ENTITY and COLL subtrees is an internal detail you
don't need to care about -- unless you want to separately configure eviction of
entities vs collections.
Note too that with RegionFactory you could just set up an eviction region for /foo and
thereby cover the entities, collections and queries. I deliberately put the timestamps in
their own /TS namespace to make this possible.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098101#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...