ehcache操作

本文介绍了一个基于EHCache的缓存管理系统实现方法,包括创建、添加、获取、删除缓存及元素等核心功能,并提供了详细的类方法说明。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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);
}

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值