kr.pe.kwonnam.hibernate4memcached.regions.CollectionMemcachedRegion Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate4-memcached-core Show documentation
Show all versions of hibernate4-memcached-core Show documentation
hibernate4 memcached L2 cache implementation.
package kr.pe.kwonnam.hibernate4memcached.regions;
import kr.pe.kwonnam.hibernate4memcached.memcached.CacheNamespace;
import kr.pe.kwonnam.hibernate4memcached.memcached.MemcachedAdapter;
import kr.pe.kwonnam.hibernate4memcached.strategies.NonstrictReadWriteCollectionRegionAccessStrategy;
import kr.pe.kwonnam.hibernate4memcached.strategies.ReadOnlyCollectionRegionAccessStrategy;
import kr.pe.kwonnam.hibernate4memcached.timestamper.HibernateCacheTimestamper;
import kr.pe.kwonnam.hibernate4memcached.util.OverridableReadOnlyProperties;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.spi.CacheDataDescription;
import org.hibernate.cache.spi.CollectionRegion;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
import org.hibernate.cfg.Settings;
/**
* @author KwonNam Son ([email protected])
*/
public class CollectionMemcachedRegion extends TransactionalDataMemcachedRegion implements CollectionRegion {
public CollectionMemcachedRegion(String regionName, OverridableReadOnlyProperties properties, CacheDataDescription metadata, Settings settings, MemcachedAdapter memcachedAdapter, HibernateCacheTimestamper hibernateCacheTimestamper) {
super(new CacheNamespace(regionName, true), properties, metadata, settings, memcachedAdapter, hibernateCacheTimestamper);
}
@Override
public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
switch (accessType) {
case READ_ONLY:
return new ReadOnlyCollectionRegionAccessStrategy(this);
case NONSTRICT_READ_WRITE:
return new NonstrictReadWriteCollectionRegionAccessStrategy(this);
default:
throw new CacheException("Unsupported access strategy : " + accessType + ".");
}
}
}