• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Cache类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.persistence.Cache的典型用法代码示例。如果您正苦于以下问题:Java Cache类的具体用法?Java Cache怎么用?Java Cache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Cache类属于javax.persistence包,在下文中一共展示了Cache类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: evictSecondLevelCache

import javax.persistence.Cache; //导入依赖的package包/类
/**
 * Evicts all second-level cache elements which could get stale on entity updates
 */
protected void evictSecondLevelCache() {
    Cache cache = entityManager.getEntityManagerFactory().getCache();

    // If this DAO is cached, evict the collection regions, as we don't know which ones will point out to it
    if (hasCache) {
        synchronized (cache) {
            // We must invalidate all collection regions, as we don't know which other entities have many-to-many relationships with this one
            cache.evict(getEntityType());
        }
    }

    // Evict the query cache region
    if (queryCacheRegion != null) {
        synchronized (cache) {
            cache.evict(getEntityType());
        }
    }
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:22,代码来源:BaseDAOImpl.java


示例2: test

import javax.persistence.Cache; //导入依赖的package包/类
@Test
public void test() {
    Cache cache = entityManager.getEntityManagerFactory().getCache();
    cache.evictAll();
    Statistics statistics = ((Session)(entityManager.getDelegate())).getSessionFactory().getStatistics();
    statistics.clear();
    
    CommonCourt commonCourt = testPersistenceObjectFactory.createCcCourt(CommonCourtType.APPEAL);
    
    commonCourtRepository.findOne(commonCourt.getId());
    commonCourtRepository.findOne(commonCourt.getId());

    Assert.assertTrue(cache.contains(CommonCourt.class, commonCourt.getId()));
    Assert.assertTrue(cache.contains(CommonCourtDivision.class, commonCourt.getDivisions().get(0).getId()));
    Assert.assertTrue(cache.contains(CommonCourtDivision.class, commonCourt.getDivisions().get(1).getId()));
    cache.evict(CommonCourt.class);
    cache.evict(CommonCourtDivision.class);
    Assert.assertFalse(cache.contains(CommonCourt.class, commonCourt.getId()));
    Assert.assertFalse(cache.contains(CommonCourtDivision.class, commonCourt.getDivisions().get(0).getId()));
    Assert.assertFalse(cache.contains(CommonCourtDivision.class, commonCourt.getDivisions().get(1).getId()));

    Assert.assertEquals(5, statistics.getSecondLevelCachePutCount()); // 1 commonCourt + 2 ccDivision + 2 ccDivisionType
    Assert.assertEquals(2, statistics.getSecondLevelCacheHitCount());
    Assert.assertEquals(0, statistics.getSecondLevelCacheMissCount());
    
}
 
开发者ID:CeON,项目名称:saos,代码行数:27,代码来源:SecondLevelCacheTest.java


示例3: createQueryCacheAndEvictAllThenRetry

import javax.persistence.Cache; //导入依赖的package包/类
@Test
public void createQueryCacheAndEvictAllThenRetry() throws Exception {
	List<Author> beforeResults = getAuthorsWithQuery("Author query", "어느나라");

	log.warn("#####################################################################");

	HibernateEntityManagerFactory entityManagerFactory = (HibernateEntityManagerFactory) EntityTestUtils.getEntityManagerFactory();
	org.hibernate.Cache cache = entityManagerFactory.getSessionFactory().getCache();
	cache.evictEntityRegions();
	cache.evictQueryRegions();
	cache.evictDefaultQueryRegion();
	cache.evictCollectionRegions();

	log.warn("just eviected all.");
	List<Author> againResults = getAuthorsWithQuery("Author query again after evict all", "어느나라");

	assertThat(againResults).isEqualTo(beforeResults);
	log.warn("#####################################################################");
}
 
开发者ID:kwon37xi,项目名称:hibernate4-memcached,代码行数:20,代码来源:QueryCacheTest.java


示例4: getCache

import javax.persistence.Cache; //导入依赖的package包/类
public Cache getCache() {
	// TODO : cache the cache reference?
	if ( ! isOpen() ) {
		throw new IllegalStateException("EntityManagerFactory is closed");
	}
	return new JPACache( sessionFactory );
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:8,代码来源:EntityManagerFactoryImpl.java


示例5: testRoomsAreCached

import javax.persistence.Cache; //导入依赖的package包/类
@Test
public void testRoomsAreCached() {
    Room room = getEntityManager().find(Room.class, WELL_KNOWN_ROOM_ID);

    assertThat(room, is(not(nullValue())));

    Cache cache = getEntityManager().getEntityManagerFactory().getCache();
    assertTrue("Rooms should be cached ", cache.contains(Room.class, room.getId()));
}
 
开发者ID:koenighotze,项目名称:Hotel-Reservation-Tool,代码行数:10,代码来源:RoomCacheTest.java


示例6: testTransientRoomsAreNotCached

import javax.persistence.Cache; //导入依赖的package包/类
@Test
public void testTransientRoomsAreNotCached() {
    Room room = new Room("", RoomEquipment.BUDGET);

    Cache cache = getEntityManager().getEntityManagerFactory().getCache();
    assertFalse("Rooms should be cached ", cache.contains(Room.class, room.getId()));
}
 
开发者ID:koenighotze,项目名称:Hotel-Reservation-Tool,代码行数:8,代码来源:RoomCacheTest.java


示例7: destroy

import javax.persistence.Cache; //导入依赖的package包/类
public static void destroy() {
    if (emf == null) {
        return;
    }

    Cache cache = emf.getCache();
    log.debug("###### EVICT ALL ######");
    cache.evictAll();
    emf.close();
}
 
开发者ID:kwon37xi,项目名称:hibernate4-memcached,代码行数:11,代码来源:EntityTestUtils.java


示例8: evict

import javax.persistence.Cache; //导入依赖的package包/类
private void evict(Cache cache, VARSObject entity) {
    try {
        cache.evict(entity.getClass(), entity.getPrimaryKey());
    }
    catch (Exception e) {
        log.info("Failed to evict " + entity + " from cache", e);
    }
}
 
开发者ID:hohonuuli,项目名称:vars,代码行数:9,代码来源:JPACacheProvider.java


示例9: invoke

import javax.persistence.Cache; //导入依赖的package包/类
@Override
public Object invoke(Object... args) {
    Cache secondLevelCache = getEntityManagerFactory(args).getCache();
    if (secondLevelCache != null) {
        secondLevelCache.evictAll();
    }
    return null;
}
 
开发者ID:jipijapa,项目名称:jipijapa,代码行数:9,代码来源:HibernateStatistics.java


示例10: getCache

import javax.persistence.Cache; //导入依赖的package包/类
@Override
public Cache getCache() {
   return nativeEntityManagerFactory.getCache();
}
 
开发者ID:Wolfgang-Winter,项目名称:cibet,代码行数:5,代码来源:CibetEntityManagerFactory.java


示例11: getCache

import javax.persistence.Cache; //导入依赖的package包/类
@Override
public Cache getCache() {
   return null;
}
 
开发者ID:Wolfgang-Winter,项目名称:cibet,代码行数:5,代码来源:JdbcBridgeEntityManagerFactory.java


示例12: getCache

import javax.persistence.Cache; //导入依赖的package包/类
public Cache getCache() {
    return delegate.getCache();
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:4,代码来源:DelegatingEntityManagerFactory.java


示例13: getCache

import javax.persistence.Cache; //导入依赖的package包/类
public Cache getCache() {
    return null;
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:4,代码来源:MockitoPersistenceProvider.java


示例14: getCache

import javax.persistence.Cache; //导入依赖的package包/类
public Cache getCache() {
    throw new UnsupportedOperationException("Not supported.");
}
 
开发者ID:victorrentea,项目名称:training,代码行数:4,代码来源:MockStockPriceEntityManagerFactory.java


示例15: getCache

import javax.persistence.Cache; //导入依赖的package包/类
@Override
public Cache getCache() {
    return null;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:5,代码来源:NoopEntityManagerFactory.java


示例16: getCache

import javax.persistence.Cache; //导入依赖的package包/类
public Cache getCache() {
	return CacheDummy.getInstance();
}
 
开发者ID:GeeQuery,项目名称:ef-orm,代码行数:4,代码来源:JefEntityManagerFactory.java


示例17: getCache

import javax.persistence.Cache; //导入依赖的package包/类
@Override
public Cache getCache() {
  return null;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:5,代码来源:JPQLBuilderFactoryTest.java


示例18: getCache

import javax.persistence.Cache; //导入依赖的package包/类
public Cache getCache() {
	return emf.getCache();
}
 
开发者ID:davidmoten,项目名称:functional-jpa,代码行数:4,代码来源:RichEntityManagerFactory.java


示例19: getCache

import javax.persistence.Cache; //导入依赖的package包/类
public Cache getCache() {
	return entityManagerFactory.getCache();
}
 
开发者ID:spearal,项目名称:spearal-jpa2,代码行数:4,代码来源:EntityManagerFactoryWrapper.java


示例20: clearCache

import javax.persistence.Cache; //导入依赖的package包/类
public DAO<T> clearCache() {
	Cache cache = entityManager.getEntityManagerFactory().getCache();
	cache.evict(entityClass);
	return this;
}
 
开发者ID:ivmarcos,项目名称:query,代码行数:6,代码来源:DAO.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PanelBuilder类代码示例发布时间:2022-05-21
下一篇:
Java PlainTextByLineStream类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap