📄 oscachepool.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 + -