📄 treecachepool.java
字号:
package org.speedframework.cache;
import java.io.Serializable;
import java.util.Hashtable;
import org.apache.jcs.access.exception.CacheException;
import org.jboss.cache.TreeCache;
/**
* JBoss Cache Pool
* @author lizf
*
*/
public class TreeCachePool implements Serializable, CachePool {
/**
*
*/
private static final long serialVersionUID = 3525766563362980882L;
private static Hashtable cachePool = new Hashtable();
private static String key = null;
private static final String SPEED_CACHE = "CACHE";
public void newInstance(String region) throws CacheException {
key = region;
if (!cachePool.containsKey(region)) {
TreeCache cache;
try {
cache = new TreeCache();
cache.setClusterProperties("treecache.xml");
cache.createService();
cache.startService();
cachePool.put(region, cache);
} catch (Exception e) {
throw new CacheException(e);
}
}
}
public void put(Object name, Object value) throws CacheException {
TreeCache cache = (TreeCache) cachePool.get(key);
try {
cache.put(SPEED_CACHE,name.toString(),value);
} catch (org.jboss.cache.CacheException e) {
throw new CacheException(e);
}
}
public Object get(Object name) throws CacheException{
TreeCache cache = (TreeCache) cachePool.get(key);
try {
return cache.get(SPEED_CACHE,name.toString());
} catch (org.jboss.cache.CacheException e) {
// throw new CacheException(e);
return null;
}
}
public String getStats() {
// return ( (TreeCache) cachePool.get(key))
return null;
}
public void putInGroup(Object name, Object value) throws
CacheException {
// ( (Cache) cachePool.get(key)).putSafe(name, value);
}
public void dispose() {
( (TreeCache) cachePool.get(key)).destroy();
cachePool.remove(key);
}
public void remove(Object name) throws CacheException {
TreeCache cache = (TreeCache) cachePool.get(key);
try {
cache.remove(name.toString());
} catch (org.jboss.cache.CacheException e) {
throw new CacheException(e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -