1
14
15 package com.liferay.portal.dao.orm.hibernate;
16
17 import com.liferay.portal.kernel.util.GetterUtil;
18 import com.liferay.portal.util.PropsUtil;
19
20 import com.opensymphony.oscache.base.CacheEntry;
21
22 import java.util.Properties;
23
24 import org.hibernate.cache.Cache;
25 import org.hibernate.cache.CacheException;
26 import org.hibernate.cache.CacheProvider;
27 import org.hibernate.cache.Timestamper;
28 import org.hibernate.util.StringHelper;
29
30
37 public class OSCacheProvider implements CacheProvider {
38
39 public static final String OSCACHE_REFRESH_PERIOD = "refresh.period";
40
41 public static final String OSCACHE_CRON = "cron";
42
43 public Cache buildCache(String region, Properties properties)
44 throws CacheException {
45
46 int refreshPeriod = GetterUtil.getInteger(
47 PropsUtil.get(StringHelper.qualify(region, OSCACHE_REFRESH_PERIOD)),
48 CacheEntry.INDEFINITE_EXPIRY);
49
50 String cron = PropsUtil.get(StringHelper.qualify(region, OSCACHE_CRON));
51
52 return new CacheWrapper(new OSCache(refreshPeriod, cron, region));
53 }
54
55 public boolean isMinimalPutsEnabledByDefault() {
56 return false;
57 }
58
59 public long nextTimestamp() {
60 return Timestamper.next();
61 }
62
63 public void start(Properties properties) throws CacheException {
64 }
65
66 public void stop() {
67 }
68
69 }