I stumbled upon this google code project Dynacache L2 cache provider for Hibernate
http://code.google.com/p/webspherehibernateadapter/
http://visitgaurav.blogspot.com/2010/12/webspheres-dynacache-hibernate-caching.html
Gaurav has got most of the code right although there are some issues with the code which I list below -
1. In org.hibernate.cache.dynacache.WASDynaCacheProvider.buildCache(String, Properties) you can create the cache programatically using com.ibm.wsspi.cache.DistributedObjectCacheFactory.getMap(String, Properties)
One of the properties passed in should have been the passed in regionName which directly maps to a cache instance in Dynacache. No need to do a JNDI lookup -
2. org.hibernate.cache.dynacache.WASDynaCache.asWASKey(Object) is unnecessary since Dynacache DistributedMap allows keys to be POJO and not just strings. Dynacache provides multiple cache regions which map 1:1 to the cache instance. There is no need to append the cache region to the cache key. Cache keys in two regions will never collide as they are separate cache instances.
3. Dynacache memory cache instance size can be specified in # of entries as well as # of bytes on a 32 bit heap. The properties below can be used to control the cache instance size in bytes. Therefore org.hibernate.cache.dynacache.WASDynaCache.getSizeInMemory() could return the max cache size in MB. Unfortunately the external interfaces dont expose the current memory in bytes that the Dynacache implementation computes
http://webspherecommunity.blogspot.com/2008/09/new-dynacache-features-in-websphere-7.html
com.ibm.wsspi.cache.DistributedObjectCacheFactory.KEY_MEMORY_CACHE_SIZE_IN_MB
com.ibm.wsspi.cache.DistributedObjectCacheFactory.KEY_MEMORY_CACHE_SIZE_HIGH_THRESHOLD
com.ibm.wsspi.cache.DistributedObjectCacheFactory.KEY_MEMORY_CACHE_SIZE_LOW_THRESHOLD
4. Apply the following JVM custom properties to tune dynacache
http://wasdynacache.blogspot.com/2011/07/tuning-dynacache-and-drs.html
http://code.google.com/p/webspherehibernateadapter/
http://visitgaurav.blogspot.com/2010/12/webspheres-dynacache-hibernate-caching.html
Gaurav has got most of the code right although there are some issues with the code which I list below -
1. In org.hibernate.cache.dynacache.WASDynaCacheProvider.buildCache(String, Properties) you can create the cache programatically using com.ibm.wsspi.cache.DistributedObjectCacheFactory.getMap(String, Properties)
One of the properties passed in should have been the passed in regionName which directly maps to a cache instance in Dynacache. No need to do a JNDI lookup -
_cacheInstanceProperties = new Properties();
_cacheInstanceProperties.put(DistributedObjectCacheFactory.KEY_CACHE_SIZE.CACHE_SIZE, String.valueOf(_cacheSize));
_cacheInstanceProperties.put(com.ibm.wsspi.cache.DistributedObjectCacheFactory.KEY_DISKCACHE_SIZE, String.valueOf(_diskCacheSize));
DistributedObjectCacheFactory.createDistributedObjectCache(_cacheName, _cacheName, _cacheInstanceProperties);2. org.hibernate.cache.dynacache.WASDynaCache.asWASKey(Object) is unnecessary since Dynacache DistributedMap allows keys to be POJO and not just strings. Dynacache provides multiple cache regions which map 1:1 to the cache instance. There is no need to append the cache region to the cache key. Cache keys in two regions will never collide as they are separate cache instances.
3. Dynacache memory cache instance size can be specified in # of entries as well as # of bytes on a 32 bit heap. The properties below can be used to control the cache instance size in bytes. Therefore org.hibernate.cache.dynacache.WASDynaCache.getSizeInMemory() could return the max cache size in MB. Unfortunately the external interfaces dont expose the current memory in bytes that the Dynacache implementation computes
http://webspherecommunity.blogspot.com/2008/09/new-dynacache-features-in-websphere-7.html
com.ibm.wsspi.cache.DistributedObjectCacheFactory.KEY_MEMORY_CACHE_SIZE_IN_MB
com.ibm.wsspi.cache.DistributedObjectCacheFactory.KEY_MEMORY_CACHE_SIZE_HIGH_THRESHOLD
com.ibm.wsspi.cache.DistributedObjectCacheFactory.KEY_MEMORY_CACHE_SIZE_LOW_THRESHOLD
4. Apply the following JVM custom properties to tune dynacache
http://wasdynacache.blogspot.com/2011/07/tuning-dynacache-and-drs.html
* The code was ASL v2 licensed which is why I was able to read and give feedback.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.