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

📄 oscache.java

📁 介绍了hibernate的入门有一些基本常用的事例
💻 JAVA
字号:
//$Id: OSCache.java,v 1.8 2005/03/16 06:01:16 oneovthafew Exp $package org.hibernate.cache;import java.util.Map;import com.opensymphony.oscache.base.NeedsRefreshException;import com.opensymphony.oscache.general.GeneralCacheAdministrator;/** * @author <a href="mailto:m.bogaert@intrasoft.be">Mathias Bogaert</a> */public class OSCache implements Cache {	/** 	 * The OSCache 2.0 cache administrator. 	 */	private GeneralCacheAdministrator cache = new GeneralCacheAdministrator();	private final int refreshPeriod;	private final String cron;	private final String regionName;		private String toString(Object key) {		return String.valueOf(key) + '.' + regionName;	}	public OSCache(int refreshPeriod, String cron, String region) {		this.refreshPeriod = refreshPeriod;		this.cron = cron;		this.regionName = region;	}	public void setCacheCapacity(int cacheCapacity) {		cache.setCacheCapacity(cacheCapacity);	}	public Object get(Object key) throws CacheException {		try {			return cache.getFromCache( toString(key), refreshPeriod, cron );		}		catch (NeedsRefreshException e) {			cache.cancelUpdate( toString(key) );			return null;		}	}	public void update(Object key, Object value) throws CacheException {		put(key, value);	}		public void put(Object key, Object value) throws CacheException {		cache.putInCache( toString(key), value );	}	public void remove(Object key) throws CacheException {		cache.flushEntry( toString(key) );	}	public void clear() throws CacheException {		cache.flushAll();	}	public void destroy() throws CacheException {		cache.destroy();	}	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 long nextTimestamp() {		return Timestamper.next();	}	public int getTimeout() {		return Timestamper.ONE_MS * 60000; //ie. 60 seconds	}	public String getRegionName() {		return regionName;	}	public long getSizeInMemory() {		return -1;	}	public long getElementCountInMemory() {		return -1;	}	public long getElementCountOnDisk() {		return -1;	}	public Map toMap() {		throw new UnsupportedOperationException();	}	public String toString() {		return "OSCache(" + regionName + ')';	}}

⌨️ 快捷键说明

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