kr.pe.kwonnam.hibernate4memcached.strategies.NonstrictReadWriteEntityRegionAccessStrategy 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.strategies;
import kr.pe.kwonnam.hibernate4memcached.regions.EntityMemcachedRegion;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.spi.access.SoftLock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author KwonNam Son ([email protected])
*/
public class NonstrictReadWriteEntityRegionAccessStrategy extends BaseEntityMemcachedRegionAccessStrategy {
private Logger log = LoggerFactory.getLogger(NonstrictReadWriteEntityRegionAccessStrategy.class);
public NonstrictReadWriteEntityRegionAccessStrategy(EntityMemcachedRegion entityMemcachedRegion) {
super(entityMemcachedRegion);
}
@Override
public boolean insert(Object key, Object value, Object version) throws CacheException {
log.debug("region access strategy nonstrict-read-write entity insert() {} {}", getInternalRegion().getCacheNamespace(), key);
// On nonstrict-read-write, Hibernate never calls this method.
return false;
}
@Override
public boolean afterInsert(Object key, Object value, Object version) throws CacheException {
log.debug("region access strategy nonstrict-read-write entity afterInsert() {} {}", getInternalRegion().getCacheNamespace(), key);
// On nonstrict-read-write, Hibernate never calls this method.
return false;
}
/**
* nostrict-read-write에서는 불필요한 작업
*
* @see org.hibernate.cache.spi.access.EntityRegionAccessStrategy
*/
@Override
public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) throws CacheException {
log.debug("region access strategy nonstrict-read-write entity update() {} {}", getInternalRegion().getCacheNamespace(), key);
return false;
}
/**
* update 후, 기존 캐시를 삭제해줘야 한다.
*
* @see org.hibernate.cache.spi.access.EntityRegionAccessStrategy
*/
@Override
public boolean afterUpdate(Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock) throws CacheException {
log.debug("region access strategy nonstrict-read-write entity afterUpdate() {} {}", getInternalRegion().getCacheNamespace(), key);
getInternalRegion().evict(key);
return false;
}
}