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

📄 oscachepool.java

📁 Speedframework--基于类型元数据的羽量级ORM.完全基于Java类型元数据和反射机制同时不需要任何对象关系映射配置文件的轻量级ORM框架,它充分利用了类型本身的信息,使用Metadata
💻 JAVA
字号:
package org.speedframework.cache;

import java.io.Serializable;
import java.util.Hashtable;


import org.apache.jcs.access.exception.CacheException;

import com.opensymphony.oscache.base.NeedsRefreshException;
import com.opensymphony.oscache.general.GeneralCacheAdministrator;

/**
 * OSCache 池
 * @author lizf
 *
 */
public class OSCachePool implements Serializable, CachePool {

	/**
	 * 
	 */
	private static final long serialVersionUID = 570900712977492631L;

	private static Hashtable cachePool = new Hashtable();
	  private static String key = null;
	  
	  public  void newInstance(String region) throws CacheException {
	    key = region;
	    if (!cachePool.containsKey(region)) {
	    	GeneralCacheAdministrator cache = new GeneralCacheAdministrator();
	        cachePool.put(region, cache);
	    }

	  }

	  public  void put(Object name, Object value) throws CacheException {
		  GeneralCacheAdministrator cache = (GeneralCacheAdministrator) cachePool.get(key);
		  cache.putInCache(name.toString(), value);
	  }

	  public  Object get(Object name)  {		 
		  GeneralCacheAdministrator cache = null;
		try {
			 cache = (GeneralCacheAdministrator) cachePool.get(key);
			 return cache.getFromCache(name.toString());
		} catch (NeedsRefreshException e) {
//			cache.putInCache(name.toString(),null);
			cache.cancelUpdate(name.toString());
			return null;
		}		
	  }

	  public  String getStats()  {
	    return ( (GeneralCacheAdministrator) cachePool.get(key)).getCache().toString();
	  }

	  public  void putInGroup(Object name, Object value) throws
	      CacheException {
//	    ( (Cache) cachePool.get(key)).putSafe(name, value);
	  }

	  public  void dispose()  {
	    ( (GeneralCacheAdministrator) cachePool.get(key)).destroy();
	    cachePool.remove(key);
	  }

	  public  void remove(Object name) throws CacheException {		 
		  GeneralCacheAdministrator cache = (GeneralCacheAdministrator) cachePool.get(key);		  
		  cache.removeEntry(name.toString());
	  }

}

⌨️ 快捷键说明

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