001
014
015 package com.liferay.portal.dao.orm.hibernate;
016
017 import com.liferay.portal.kernel.util.GetterUtil;
018 import com.liferay.portal.util.PropsUtil;
019
020 import com.opensymphony.oscache.base.CacheEntry;
021
022 import java.util.Properties;
023
024 import org.hibernate.cache.Cache;
025 import org.hibernate.cache.CacheException;
026 import org.hibernate.cache.CacheProvider;
027 import org.hibernate.cache.Timestamper;
028 import org.hibernate.util.StringHelper;
029
030
035 public class OSCacheProvider implements CacheProvider {
036
037 public static final String OSCACHE_REFRESH_PERIOD = "refresh.period";
038
039 public static final String OSCACHE_CRON = "cron";
040
041 public Cache buildCache(String region, Properties properties)
042 throws CacheException {
043
044 int refreshPeriod = GetterUtil.getInteger(
045 PropsUtil.get(StringHelper.qualify(region, OSCACHE_REFRESH_PERIOD)),
046 CacheEntry.INDEFINITE_EXPIRY);
047
048 String cron = PropsUtil.get(StringHelper.qualify(region, OSCACHE_CRON));
049
050 return new CacheWrapper(new OSCache(refreshPeriod, cron, region));
051 }
052
053 public boolean isMinimalPutsEnabledByDefault() {
054 return false;
055 }
056
057 public long nextTimestamp() {
058 return Timestamper.next();
059 }
060
061 public void start(Properties properties) throws CacheException {
062 }
063
064 public void stop() {
065 }
066
067 }