⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jcscache.java

📁 用Java实现的23个常用设计模式源代码
💻 JAVA
字号:
//$Id: JCSCache.java,v 1.5.2.8 2003/11/16 16:03:29 oneovthafew Exp $package net.sf.hibernate.cache;import org.apache.commons.logging.LogFactory;import org.apache.commons.logging.Log;import org.apache.jcs.JCS;/** * Support for Apache Turbine's JCS * @author Gavin King * @deprecated JCS support will be removed in version 2.1.1 */public class JCSCache implements Cache {		private static final Log log = LogFactory.getLog(JCSCache.class);		private JCS region;		public JCSCache(String regionName, java.util.Properties properties) throws CacheException {				try {			region = JCS.getInstance(regionName);		}		catch (org.apache.jcs.access.exception.CacheException e) {			log.error("could not create JCS region", e);			throw new CacheException(e);		}	}		public Object get(Object key) {		return region.get(key);	}		public void put(Object key, Object value) throws CacheException {		try {			region.put(key, value);		}		catch (org.apache.jcs.access.exception.CacheException e) {			log.error("could not add to JCS region", e);			throw new CacheException(e);		}	}		public void remove(Object key) throws CacheException {		try {			region.remove(key);		}		catch (org.apache.jcs.access.exception.CacheException e) {			log.error("could not remove from JCS region", e);			throw new CacheException(e);		}	}	public void clear() throws CacheException {		try {			region.remove();		}		catch (org.apache.jcs.access.exception.CacheException e) {			log.error("could not remove from JCS region", e);			throw new CacheException(e);		}	}	public void destroy() throws CacheException {		try {			region.destroy();		}		catch (org.apache.jcs.access.exception.CacheException e) {			log.error("could not destroy JCS region", e);			throw new CacheException(e);		}	}	public long nextTimestamp() {		return Timestamper.next();	}	public void lock(Object key) throws CacheException {		//local cache, so we use synchronization	}	public void unlock(Object key) throws CacheException {		//local cache, so we use synchronization	}	public int getTimeout() {		return Timestamper.ONE_MS * 60000; //ie. 60 seconds	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -