public class DisposeCache
{
private CacheManager singletonManager;
private String EHCACHE_NAME = "COM.HUAWEI.TBSC";
/**
* create CacheManager
*/
public DisposeCache() throws CacheException
{
if (null == singletonManager)
{
singletonManager = CacheManager.getInstance();
}
}
/**
* add Cache to CacheManager
*/
public void addCache(String name) throws IllegalStateException, ObjectExistsException, CacheException
{
singletonManager.addCache(name);
}
/**
* remove Cache from CacheManager
*/
public void removeCache(String name) throws IllegalStateException
{
singletonManager.removeCache(name);
}
/**
* shutdown CacheManager
*/
public void shutdown()
{
singletonManager.shutdown();
}
/**
* getCache from CacheManager
*/
public Cache getCache() throws IllegalStateException, ClassCastException
{
return singletonManager.getCache(EHCACHE_NAME);
}
/**
* create element to cache
*/
public void create(String key, Object value) throws IllegalArgumentException, IllegalStateException, CacheException
{
Element element = new Element(key, value);
getCache().put(element);
}
/**
* getValue form cache
*/
public Object getValue(String key) throws IllegalStateException, CacheException
{
Element element = getCache().get(key);
return element.getObjectValue();
}
/**
* remove cache
*/
public void remove(String key) throws IllegalStateException
{
getCache().remove(key);
}
}
{
private CacheManager singletonManager;
private String EHCACHE_NAME = "COM.HUAWEI.TBSC";
/**
* create CacheManager
*/
public DisposeCache() throws CacheException
{
if (null == singletonManager)
{
singletonManager = CacheManager.getInstance();
}
}
/**
* add Cache to CacheManager
*/
public void addCache(String name) throws IllegalStateException, ObjectExistsException, CacheException
{
singletonManager.addCache(name);
}
/**
* remove Cache from CacheManager
*/
public void removeCache(String name) throws IllegalStateException
{
singletonManager.removeCache(name);
}
/**
* shutdown CacheManager
*/
public void shutdown()
{
singletonManager.shutdown();
}
/**
* getCache from CacheManager
*/
public Cache getCache() throws IllegalStateException, ClassCastException
{
return singletonManager.getCache(EHCACHE_NAME);
}
/**
* create element to cache
*/
public void create(String key, Object value) throws IllegalArgumentException, IllegalStateException, CacheException
{
Element element = new Element(key, value);
getCache().put(element);
}
/**
* getValue form cache
*/
public Object getValue(String key) throws IllegalStateException, CacheException
{
Element element = getCache().get(key);
return element.getObjectValue();
}
/**
* remove cache
*/
public void remove(String key) throws IllegalStateException
{
getCache().remove(key);
}
}
本文介绍了一个基于EHCache的缓存管理系统实现方法,包括创建、添加、获取、删除缓存及元素等核心功能,并提供了详细的类方法说明。
1万+

被折叠的 条评论
为什么被折叠?



