当前位置: 首页>>代码示例>>Java>>正文


Java CacheManager类代码示例

本文整理汇总了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);
	}
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:24,代码来源:EnchachePooFactory.java

示例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"));
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:26,代码来源:ConfigurationResourceTest.java

示例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);

}
 
开发者ID:lq10001,项目名称:product,代码行数:20,代码来源:ProductlevelAction.java

示例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);

}
 
开发者ID:lq10001,项目名称:product,代码行数:20,代码来源:AporialevelAction.java

示例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);
}
 
开发者ID:ligoj,项目名称:plugin-id,代码行数:18,代码来源:AbstractContainerResourceTest.java

示例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);

}
 
开发者ID:lq10001,项目名称:product,代码行数:20,代码来源:TechnicalpointAction.java

示例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);

}
 
开发者ID:lq10001,项目名称:product,代码行数:20,代码来源:AporiaAction.java

示例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);

}
 
开发者ID:lq10001,项目名称:product,代码行数:20,代码来源:ProductAction.java

示例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();

}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:23,代码来源:TicketRegistryDecoratorTests.java

示例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;
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_04,代码行数:11,代码来源:EhcacheHelper.java

示例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);

}
 
开发者ID:lq10001,项目名称:crm,代码行数:14,代码来源:LinktypeAction.java

示例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();
}
 
开发者ID:lq10001,项目名称:crm,代码行数:14,代码来源:EmployeeService.java

示例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);

}
 
开发者ID:lq10001,项目名称:crm,代码行数:14,代码来源:EmployeeAction.java

示例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();
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:16,代码来源:LdapPluginResourceTest.java

示例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();
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:11,代码来源:LdapPluginResourceTest.java


注:本文中的net.sf.ehcache.CacheManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。