本文整理匯總了Java中net.sf.ehcache.CacheManager類的典型用法代碼示例。如果您正苦於以下問題:Java CacheManager類的具體用法?Java CacheManager怎麽用?Java CacheManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CacheManager類屬於net.sf.ehcache包,在下文中一共展示了CacheManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createCachePool
import net.sf.ehcache.CacheManager; //導入依賴的package包/類
@Override
public CachePool createCachePool(String poolName, int cacheSize,
int expiredSeconds) {
CacheManager cacheManager = CacheManager.create();
Cache enCache = cacheManager.getCache(poolName);
if (enCache == null) {
CacheConfiguration cacheConf = cacheManager.getConfiguration()
.getDefaultCacheConfiguration().clone();
cacheConf.setName(poolName);
if (cacheConf.getMaxEntriesLocalHeap() != 0) {
cacheConf.setMaxEntriesLocalHeap(cacheSize);
} else {
cacheConf.setMaxBytesLocalHeap(String.valueOf(cacheSize));
}
cacheConf.setTimeToIdleSeconds(expiredSeconds);
Cache cache = new Cache(cacheConf);
cacheManager.addCache(cache);
return new EnchachePool(poolName,cache,cacheSize);
} else {
return new EnchachePool(poolName,enCache,cacheSize);
}
}
示例2: update
import net.sf.ehcache.CacheManager; //導入依賴的package包/類
@Test
public void update() {
final SystemConfiguration value = em.createQuery("FROM SystemConfiguration WHERE name=:name", SystemConfiguration.class)
.setParameter("name", "test-key5").getSingleResult();
em.clear();
Assert.assertNotEquals("new-value-db5", value.getValue());
Assert.assertEquals("value-db5", resource.get("test-key5"));
resource.saveOrUpdate("test-key5", "new-value-db5");
// Check the data from the cache
Assert.assertEquals("new-value-db5", resource.get("test-key5"));
SystemConfiguration newValue = em.createQuery("FROM SystemConfiguration WHERE name=:name", SystemConfiguration.class)
.setParameter("name", "test-key5").getSingleResult();
// Check data is encrypted
Assert.assertNotEquals("new-value-db5", newValue.getValue());
Assert.assertEquals("new-value-db5", cryptoHelper.decrypt(newValue.getValue()));
// Check previous id is kept
Assert.assertEquals(value.getId(), newValue.getId());
// Check persistence of data and cache
CacheManager.getInstance().getCache("configuration").removeAll();
Assert.assertEquals("new-value-db5", resource.get("test-key5"));
}
示例3: save
import net.sf.ehcache.CacheManager; //導入依賴的package包/類
@At
@Ok("json")
public Map<String,String> save(@Param("action")int action,
@Param("..")Productlevel productlevel){
Object rtnObject;
if (productlevel.getId() == null || productlevel.getId() == 0) {
rtnObject = productlevelService.dao().insert(productlevel);
}else{
if (action == 3) {
productlevel.setId(null);
rtnObject = productlevelService.dao().insert(productlevel);
}else{
rtnObject = productlevelService.dao().updateIgnoreNull(productlevel);
}
}
CacheManager.getInstance().getCache(ProductlevelService.CACHE_NAME).removeAll();
return Bjui.rtnMap((rtnObject == null) ? false : true, "tab_productlevel", true);
}
示例4: save
import net.sf.ehcache.CacheManager; //導入依賴的package包/類
@At
@Ok("json")
public Map<String, String> save(@Param("action") int action,
@Param("..") Aporialevel aporialevel) {
Object rtnObject;
if (aporialevel.getId() == null || aporialevel.getId() == 0) {
rtnObject = aporialevelService.dao().insert(aporialevel);
} else {
if (action == 3) {
aporialevel.setId(null);
rtnObject = aporialevelService.dao().insert(aporialevel);
} else {
rtnObject = aporialevelService.dao().updateIgnoreNull(aporialevel);
}
}
CacheManager.getInstance().getCache(AporialevelService.CACHE_NAME).removeAll();
return Bjui.rtnMap((rtnObject == null) ? false : true, "tab_aporialevel", true);
}
示例5: prepareData
import net.sf.ehcache.CacheManager; //導入依賴的package包/類
@Before
public void prepareData() throws IOException {
persistEntities("csv",
new Class[] { DelegateOrg.class, ContainerScope.class, CacheCompany.class, CacheUser.class, CacheGroup.class, CacheMembership.class },
StandardCharsets.UTF_8.name());
CacheManager.getInstance().getCache("container-scopes").removeAll();
iamProvider = Mockito.mock(IamProvider.class);
final IamConfiguration configuration = Mockito.mock(IamConfiguration.class);
Mockito.when(iamProvider.getConfiguration()).thenReturn(configuration);
userRepository = Mockito.mock(IUserRepository.class);
groupRepository = Mockito.mock(IGroupRepository.class);
companyRepository = Mockito.mock(ICompanyRepository.class);
Mockito.when(configuration.getUserRepository()).thenReturn(userRepository);
Mockito.when(configuration.getCompanyRepository()).thenReturn(companyRepository);
Mockito.when(configuration.getGroupRepository()).thenReturn(groupRepository);
}
示例6: save
import net.sf.ehcache.CacheManager; //導入依賴的package包/類
@At
@Ok("json")
public Map<String,String> save(@Param("action")int action,
@Param("..")Technicalpoint technicalpoint){
Object rtnObject;
if (technicalpoint.getId() == null || technicalpoint.getId() == 0) {
rtnObject = technicalpointService.dao().insert(technicalpoint);
}else{
if (action == 3) {
technicalpoint.setId(null);
rtnObject = technicalpointService.dao().insert(technicalpoint);
}else{
rtnObject = technicalpointService.dao().updateIgnoreNull(technicalpoint);
}
}
CacheManager.getInstance().getCache(TechnicalpointService.CACHE_NAME).removeAll();
return Bjui.rtnMap((rtnObject == null) ? false : true, "tab_technicalpoint", true);
}
示例7: save
import net.sf.ehcache.CacheManager; //導入依賴的package包/類
@At
@Ok("json")
public Map<String,String> save(@Param("action")int action,
@Param("..")Aporia aporia){
Object rtnObject;
if (aporia.getId() == null || aporia.getId() == 0) {
rtnObject = aporiaService.dao().insert(aporia);
}else{
if (action == 3) {
aporia.setId(null);
rtnObject = aporiaService.dao().insert(aporia);
}else{
rtnObject = aporiaService.dao().updateIgnoreNull(aporia);
}
}
CacheManager.getInstance().getCache(AporiaService.CACHE_NAME).removeAll();
return Bjui.rtnMap((rtnObject == null) ? false : true, "tab_aporia", true);
}
示例8: save
import net.sf.ehcache.CacheManager; //導入依賴的package包/類
@At
@Ok("json")
public Map<String,String> save(@Param("action")int action,
@Param("..")Product product){
Object rtnObject;
if (product.getId() == null || product.getId() == 0) {
rtnObject = productService.dao().insert(product);
}else{
if (action == 3) {
product.setId(null);
rtnObject = productService.dao().insert(product);
}else{
rtnObject = productService.dao().updateIgnoreNull(product);
}
}
CacheManager.getInstance().getCache(ProductService.CACHE_NAME).removeAll();
return Bjui.rtnMap((rtnObject == null) ? false : true, "tab_product", true);
}
示例9: verifyEhCacheTicketRegistryWithClearPass
import net.sf.ehcache.CacheManager; //導入依賴的package包/類
@Test
public void verifyEhCacheTicketRegistryWithClearPass() {
final Cache serviceTicketsCache = new Cache("serviceTicketsCache", 200, false, false, 100, 100);
final Cache ticketGrantingTicketCache = new Cache("ticketGrantingTicketCache", 200, false, false, 100, 100);
final CacheManager manager = new CacheManager(this.getClass().getClassLoader().getResourceAsStream("ehcacheClearPass.xml"));
manager.addCache(serviceTicketsCache);
manager.addCache(ticketGrantingTicketCache);
final Map<String, String> map = new HashMap<>();
final TicketRegistry ticketRegistry = new EhCacheTicketRegistry(serviceTicketsCache, ticketGrantingTicketCache);
final TicketRegistryDecorator decorator = new TicketRegistryDecorator(ticketRegistry, map);
assertNotNull(decorator);
assertEquals(decorator.serviceTicketCount(), 0);
assertEquals(decorator.sessionCount(), 0);
manager.removalAll();
manager.shutdown();
}
示例10: createLifeCache
import net.sf.ehcache.CacheManager; //導入依賴的package包/類
static Cache createLifeCache(CacheManager manager, String name) {
CacheConfiguration configuration = new CacheConfiguration(name, MAX_ENTRIES);
configuration.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.FIFO)
.timeToLiveSeconds(LIFE_TIME_SEC);
Cache cache = new Cache(configuration);
manager.addCache(cache);
return cache;
}
示例11: save
import net.sf.ehcache.CacheManager; //導入依賴的package包/類
@At
@Ok("json")
public Map<String,String> save( @Param("..")Linktype linktype){
Object rtnObject;
if (linktype.getId() == null || linktype.getId() == 0) {
rtnObject = linktypeService.dao().insert(linktype);
}else{
rtnObject = linktypeService.dao().updateIgnoreNull(linktype);
}
CacheManager.getInstance().getCache(LinktypeService.CACHE_NAME).removeAll();
return Bjui.rtnMap((rtnObject == null) ? false : true, "tab_linktype", true);
}
示例12: listCount
import net.sf.ehcache.CacheManager; //導入依賴的package包/類
public int listCount(Cnd c)
{
Long num = 0L;
Cache cache = CacheManager.getInstance().getCache(CACHE_NAME);
if(cache.get(CACHE_COUNT_KEY) == null)
{
num = Long.valueOf(this.count(c));
cache.put(new Element(CACHE_COUNT_KEY, num));
}else{
num = (Long)cache.get(CACHE_COUNT_KEY).getObjectValue();
}
return num.intValue();
}
示例13: save
import net.sf.ehcache.CacheManager; //導入依賴的package包/類
@At
@Ok("json")
public Map<String,String> save( @Param("..")Employee employee){
Object rtnObject;
if (employee.getId() == null || employee.getId() == 0) {
rtnObject = employeeService.dao().insert(employee);
}else{
rtnObject = employeeService.dao().updateIgnoreNull(employee);
}
CacheManager.getInstance().getCache(EmployeeService.CACHE_NAME).removeAll();
return Bjui.rtnMap((rtnObject == null) ? false : true, "tab_employee", true);
}
示例14: prepareData
import net.sf.ehcache.CacheManager; //導入依賴的package包/類
@Before
public void prepareData() throws IOException {
persistEntities(
"csv", new Class[] { DelegateOrg.class, ContainerScope.class, CacheCompany.class, CacheUser.class, CacheGroup.class,
CacheMembership.class, Project.class, Node.class, Parameter.class, Subscription.class, ParameterValue.class,
CacheProjectGroup.class },
StandardCharsets.UTF_8.name());
CacheManager.getInstance().getCache("container-scopes").removeAll();
// Only with Spring context
this.subscription = getSubscription("gStack", IdentityResource.SERVICE_KEY);
// Coverage only
resource.getKey();
}
示例15: reloadLdapCache
import net.sf.ehcache.CacheManager; //導入依賴的package包/類
/**
* Reload the LDAP cache
*/
private void reloadLdapCache() {
// Ensure LDAP cache is loaded
CacheManager.getInstance().getCache("ldap").removeAll();
cache.getLdapData();
em.flush();
em.clear();
}