1 5 package org.exoplatform.services.database.impl; 6 7 import java.io.Serializable ; 8 import org.exoplatform.commons.utils.ExceptionUtil; 9 import org.exoplatform.services.cache.ExoCache; 10 11 import net.sf.hibernate.cache.CacheException; 12 import net.sf.hibernate.cache.Timestamper; 13 14 20 public class ExoCachePlugin implements net.sf.hibernate.cache.Cache { 21 private ExoCache cache_ ; 22 23 public ExoCachePlugin(ExoCache cache) { 24 cache_ = cache ; 25 } 26 27 public Object get(Object key) throws CacheException { 28 try { 30 return cache_.get((Serializable )key) ; 31 } catch (Exception ex) { 32 throw new CacheException(ex) ; 33 } 34 } 35 36 public void put(Object key, Object value) throws CacheException { 37 try { 39 cache_.put((Serializable )key, value) ; 40 } catch (Exception ex) { 41 throw new CacheException(ex) ; 42 } 43 } 44 45 public void remove(Object key) throws CacheException { 46 try { 48 cache_.remove((Serializable )key) ; 49 } catch (Exception ex) { 50 throw new CacheException(ex) ; 51 } 52 } 53 54 public void clear() throws CacheException { 55 try { 57 cache_.clear() ; 58 } catch (Exception ex) { 59 throw new CacheException(ex) ; 60 } 61 } 62 63 public void destroy() throws CacheException { 64 } 66 67 public void lock(Object key) throws CacheException { 68 } 69 70 71 public void unlock(Object key) throws CacheException { 72 } 73 74 public long nextTimestamp() { return Timestamper.next(); } 75 76 79 public int getTimeout() { return Timestamper.ONE_MS * 60000; } 80 } | Popular Tags |