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

Java LruCache类代码示例

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

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



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

示例1: useNewCache

import org.apache.ibatis.cache.decorators.LruCache; //导入依赖的package包/类
public Cache useNewCache(Class<? extends Cache> typeClass,
    Class<? extends Cache> evictionClass,
    Long flushInterval,
    Integer size,
    boolean readWrite,
    boolean blocking,
    Properties props) {
  Cache cache = new CacheBuilder(currentNamespace)
      .implementation(valueOrDefault(typeClass, PerpetualCache.class))
      .addDecorator(valueOrDefault(evictionClass, LruCache.class))
      .clearInterval(flushInterval)
      .size(size)
      .readWrite(readWrite)
      .blocking(blocking)
      .properties(props)
      .build();
  configuration.addCache(cache);
  currentCache = cache;
  return cache;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:21,代码来源:MapperBuilderAssistant.java


示例2: useNewCache

import org.apache.ibatis.cache.decorators.LruCache; //导入依赖的package包/类
public Cache useNewCache(Class<? extends Cache> typeClass,
    Class<? extends Cache> evictionClass,
    Long flushInterval,
    Integer size,
    boolean readWrite,
    boolean blocking,
    Properties props) {
    //这里面又判断了一下是否为null就用默认值,有点和XMLMapperBuilder.cacheElement逻辑重复了
  typeClass = valueOrDefault(typeClass, PerpetualCache.class);
  evictionClass = valueOrDefault(evictionClass, LruCache.class);
  //调用CacheBuilder构建cache,id=currentNamespace
  Cache cache = new CacheBuilder(currentNamespace)
      .implementation(typeClass)
      .addDecorator(evictionClass)
      .clearInterval(flushInterval)
      .size(size)
      .readWrite(readWrite)
      .blocking(blocking)
      .properties(props)
      .build();
  //加入缓存
  configuration.addCache(cache);
  //当前的缓存
  currentCache = cache;
  return cache;
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:27,代码来源:MapperBuilderAssistant.java


示例3: useNewCache

import org.apache.ibatis.cache.decorators.LruCache; //导入依赖的package包/类
public Cache useNewCache(Class<? extends Cache> typeClass,
    Class<? extends Cache> evictionClass,
    Long flushInterval,
    Integer size,
    boolean readWrite,
    boolean blocking,
    Properties props) {
  typeClass = valueOrDefault(typeClass, PerpetualCache.class);
  evictionClass = valueOrDefault(evictionClass, LruCache.class);
  Cache cache = new CacheBuilder(currentNamespace)
      .implementation(typeClass)
      .addDecorator(evictionClass)
      .clearInterval(flushInterval)
      .size(size)
      .readWrite(readWrite)
      .blocking(blocking)
      .properties(props)
      .build();
  configuration.addCache(cache);
  currentCache = cache;
  return cache;
}
 
开发者ID:toulezu,项目名称:play,代码行数:23,代码来源:MapperBuilderAssistant.java


示例4: setDefaultImplementations

import org.apache.ibatis.cache.decorators.LruCache; //导入依赖的package包/类
private void setDefaultImplementations() {
  if (implementation == null) {
    implementation = PerpetualCache.class;
    if (decorators.isEmpty()) {
      decorators.add(LruCache.class);
    }
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:9,代码来源:CacheBuilder.java


示例5: Configuration

import org.apache.ibatis.cache.decorators.LruCache; //导入依赖的package包/类
public Configuration() {
  typeAliasRegistry.registerAlias("JDBC", JdbcTransactionFactory.class);
  typeAliasRegistry.registerAlias("MANAGED", ManagedTransactionFactory.class);

  typeAliasRegistry.registerAlias("JNDI", JndiDataSourceFactory.class);
  typeAliasRegistry.registerAlias("POOLED", PooledDataSourceFactory.class);
  typeAliasRegistry.registerAlias("UNPOOLED", UnpooledDataSourceFactory.class);

  typeAliasRegistry.registerAlias("PERPETUAL", PerpetualCache.class);
  typeAliasRegistry.registerAlias("FIFO", FifoCache.class);
  typeAliasRegistry.registerAlias("LRU", LruCache.class);
  typeAliasRegistry.registerAlias("SOFT", SoftCache.class);
  typeAliasRegistry.registerAlias("WEAK", WeakCache.class);

  typeAliasRegistry.registerAlias("DB_VENDOR", VendorDatabaseIdProvider.class);

  typeAliasRegistry.registerAlias("XML", XMLLanguageDriver.class);
  typeAliasRegistry.registerAlias("RAW", RawLanguageDriver.class);

  typeAliasRegistry.registerAlias("SLF4J", Slf4jImpl.class);
  typeAliasRegistry.registerAlias("COMMONS_LOGGING", JakartaCommonsLoggingImpl.class);
  typeAliasRegistry.registerAlias("LOG4J", Log4jImpl.class);
  typeAliasRegistry.registerAlias("LOG4J2", Log4j2Impl.class);
  typeAliasRegistry.registerAlias("JDK_LOGGING", Jdk14LoggingImpl.class);
  typeAliasRegistry.registerAlias("STDOUT_LOGGING", StdOutImpl.class);
  typeAliasRegistry.registerAlias("NO_LOGGING", NoLoggingImpl.class);

  typeAliasRegistry.registerAlias("CGLIB", CglibProxyFactory.class);
  typeAliasRegistry.registerAlias("JAVASSIST", JavassistProxyFactory.class);

  languageRegistry.setDefaultDriverClass(XMLLanguageDriver.class);
  languageRegistry.register(RawLanguageDriver.class);
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:34,代码来源:Configuration.java


示例6: shouldRemoveLeastRecentlyUsedItemInBeyondFiveEntries

import org.apache.ibatis.cache.decorators.LruCache; //导入依赖的package包/类
@Test
public void shouldRemoveLeastRecentlyUsedItemInBeyondFiveEntries() {
  LruCache cache = new LruCache(new PerpetualCache("default"));
  cache.setSize(5);
  for (int i = 0; i < 5; i++) {
    cache.putObject(i, i);
  }
  assertEquals(0, cache.getObject(0));
  cache.putObject(5, 5);
  assertNull(cache.getObject(1));
  assertEquals(5, cache.getSize());
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:13,代码来源:LruCacheTest.java


示例7: shouldRemoveItemOnDemand

import org.apache.ibatis.cache.decorators.LruCache; //导入依赖的package包/类
@Test
public void shouldRemoveItemOnDemand() {
  Cache cache = new LruCache(new PerpetualCache("default"));
  cache.putObject(0, 0);
  assertNotNull(cache.getObject(0));
  cache.removeObject(0);
  assertNull(cache.getObject(0));
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:9,代码来源:LruCacheTest.java


示例8: shouldFlushAllItemsOnDemand

import org.apache.ibatis.cache.decorators.LruCache; //导入依赖的package包/类
@Test
public void shouldFlushAllItemsOnDemand() {
  Cache cache = new LruCache(new PerpetualCache("default"));
  for (int i = 0; i < 5; i++) {
    cache.putObject(i, i);
  }
  assertNotNull(cache.getObject(0));
  assertNotNull(cache.getObject(4));
  cache.clear();
  assertNull(cache.getObject(0));
  assertNull(cache.getObject(4));
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:13,代码来源:LruCacheTest.java


示例9: Configuration

import org.apache.ibatis.cache.decorators.LruCache; //导入依赖的package包/类
public Configuration() {
  // 源码解析: 注册事务工厂别名
  typeAliasRegistry.registerAlias("JDBC", JdbcTransactionFactory.class);
  typeAliasRegistry.registerAlias("MANAGED", ManagedTransactionFactory.class);

  // 源码解析: 注册数据源工厂别名
  typeAliasRegistry.registerAlias("JNDI", JndiDataSourceFactory.class);
  typeAliasRegistry.registerAlias("POOLED", PooledDataSourceFactory.class);
  typeAliasRegistry.registerAlias("UNPOOLED", UnpooledDataSourceFactory.class);

  // 源码解析: 注册缓存别名
  typeAliasRegistry.registerAlias("PERPETUAL", PerpetualCache.class);
  typeAliasRegistry.registerAlias("FIFO", FifoCache.class);
  typeAliasRegistry.registerAlias("LRU", LruCache.class);
  typeAliasRegistry.registerAlias("SOFT", SoftCache.class);
  typeAliasRegistry.registerAlias("WEAK", WeakCache.class);

  // 源码解析: 注册VendorDatabaseIdProvider别名
  typeAliasRegistry.registerAlias("DB_VENDOR", VendorDatabaseIdProvider.class);

  // 源码解析: 注册LanguageDriver别名
  typeAliasRegistry.registerAlias("XML", XMLLanguageDriver.class);
  typeAliasRegistry.registerAlias("RAW", RawLanguageDriver.class);

  // 源码解析: 注册日志实现别名
  typeAliasRegistry.registerAlias("SLF4J", Slf4jImpl.class);
  typeAliasRegistry.registerAlias("COMMONS_LOGGING", JakartaCommonsLoggingImpl.class);
  typeAliasRegistry.registerAlias("LOG4J", Log4jImpl.class);
  typeAliasRegistry.registerAlias("LOG4J2", Log4j2Impl.class);
  typeAliasRegistry.registerAlias("JDK_LOGGING", Jdk14LoggingImpl.class);
  typeAliasRegistry.registerAlias("STDOUT_LOGGING", StdOutImpl.class);
  typeAliasRegistry.registerAlias("NO_LOGGING", NoLoggingImpl.class);

  // 源码解析: 注册代理工厂别名
  typeAliasRegistry.registerAlias("CGLIB", CglibProxyFactory.class);
  typeAliasRegistry.registerAlias("JAVASSIST", JavassistProxyFactory.class);

  languageRegistry.setDefaultDriverClass(XMLLanguageDriver.class);
  languageRegistry.register(RawLanguageDriver.class);
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:41,代码来源:Configuration.java


示例10: Configuration

import org.apache.ibatis.cache.decorators.LruCache; //导入依赖的package包/类
public Configuration() {
	typeAliasRegistry.registerAlias("JDBC", JdbcTransactionFactory.class);
	typeAliasRegistry.registerAlias("MANAGED",
			ManagedTransactionFactory.class);

	typeAliasRegistry.registerAlias("JNDI", JndiDataSourceFactory.class);
	typeAliasRegistry
			.registerAlias("POOLED", PooledDataSourceFactory.class);
	typeAliasRegistry.registerAlias("UNPOOLED",
			UnpooledDataSourceFactory.class);

	typeAliasRegistry.registerAlias("PERPETUAL", PerpetualCache.class);
	typeAliasRegistry.registerAlias("FIFO", FifoCache.class);
	typeAliasRegistry.registerAlias("LRU", LruCache.class);
	typeAliasRegistry.registerAlias("SOFT", SoftCache.class);
	typeAliasRegistry.registerAlias("WEAK", WeakCache.class);

	typeAliasRegistry.registerAlias("DB_VENDOR",
			VendorDatabaseIdProvider.class);

	typeAliasRegistry.registerAlias("XML", XMLLanguageDriver.class);
	typeAliasRegistry.registerAlias("RAW", RawLanguageDriver.class);

	typeAliasRegistry.registerAlias("SLF4J", Slf4jImpl.class);
	typeAliasRegistry.registerAlias("COMMONS_LOGGING",
			JakartaCommonsLoggingImpl.class);
	typeAliasRegistry.registerAlias("LOG4J", Log4jImpl.class);
	typeAliasRegistry.registerAlias("LOG4J2", Log4j2Impl.class);
	typeAliasRegistry.registerAlias("JDK_LOGGING", Jdk14LoggingImpl.class);
	typeAliasRegistry.registerAlias("STDOUT_LOGGING", StdOutImpl.class);
	typeAliasRegistry.registerAlias("NO_LOGGING", NoLoggingImpl.class);

	typeAliasRegistry.registerAlias("CGLIB", CglibProxyFactory.class);
	typeAliasRegistry.registerAlias("JAVASSIST",
			JavassistProxyFactory.class);

	languageRegistry.setDefaultDriverClass(XMLLanguageDriver.class);
	languageRegistry.register(RawLanguageDriver.class);
}
 
开发者ID:EleTeam,项目名称:Shop-for-JavaWeb,代码行数:40,代码来源:Configuration.java


示例11: Configuration

import org.apache.ibatis.cache.decorators.LruCache; //导入依赖的package包/类
public Configuration() {
	typeAliasRegistry.registerAlias("JDBC", JdbcTransactionFactory.class);
	typeAliasRegistry.registerAlias("MANAGED", ManagedTransactionFactory.class);

	typeAliasRegistry.registerAlias("JNDI", JndiDataSourceFactory.class);
	typeAliasRegistry.registerAlias("POOLED", PooledDataSourceFactory.class);
	typeAliasRegistry.registerAlias("UNPOOLED", UnpooledDataSourceFactory.class);

	typeAliasRegistry.registerAlias("PERPETUAL", PerpetualCache.class);
	typeAliasRegistry.registerAlias("FIFO", FifoCache.class);
	typeAliasRegistry.registerAlias("LRU", LruCache.class);
	typeAliasRegistry.registerAlias("SOFT", SoftCache.class);
	typeAliasRegistry.registerAlias("WEAK", WeakCache.class);

	typeAliasRegistry.registerAlias("DB_VENDOR", VendorDatabaseIdProvider.class);

	typeAliasRegistry.registerAlias("XML", XMLLanguageDriver.class);
	typeAliasRegistry.registerAlias("RAW", RawLanguageDriver.class);

	typeAliasRegistry.registerAlias("SLF4J", Slf4jImpl.class);
	typeAliasRegistry.registerAlias("COMMONS_LOGGING", JakartaCommonsLoggingImpl.class);
	typeAliasRegistry.registerAlias("LOG4J", Log4jImpl.class);
	typeAliasRegistry.registerAlias("LOG4J2", Log4j2Impl.class);
	typeAliasRegistry.registerAlias("JDK_LOGGING", Jdk14LoggingImpl.class);
	typeAliasRegistry.registerAlias("STDOUT_LOGGING", StdOutImpl.class);
	typeAliasRegistry.registerAlias("NO_LOGGING", NoLoggingImpl.class);

	typeAliasRegistry.registerAlias("CGLIB", CglibProxyFactory.class);
	typeAliasRegistry.registerAlias("JAVASSIST", JavassistProxyFactory.class);

	languageRegistry.setDefaultDriverClass(XMLLanguageDriver.class);
	languageRegistry.register(RawLanguageDriver.class);
}
 
开发者ID:whatlookingfor,项目名称:spring-boot-sample,代码行数:34,代码来源:Configuration.java


示例12: setDefaultImplementations

import org.apache.ibatis.cache.decorators.LruCache; //导入依赖的package包/类
private void setDefaultImplementations() {
    //又是一重保险,如果为null则设默认值,和XMLMapperBuilder.cacheElement以及MapperBuilderAssistant.useNewCache逻辑重复了
  if (implementation == null) {
    implementation = PerpetualCache.class;
    if (decorators.isEmpty()) {
      decorators.add(LruCache.class);
    }
  }
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:10,代码来源:CacheBuilder.java


示例13: Configuration

import org.apache.ibatis.cache.decorators.LruCache; //导入依赖的package包/类
public Configuration() {
  //注册更多的类型别名,至于为何不直接在TypeAliasRegistry里注册,还需进一步研究
  typeAliasRegistry.registerAlias("JDBC", JdbcTransactionFactory.class);
  typeAliasRegistry.registerAlias("MANAGED", ManagedTransactionFactory.class);

  typeAliasRegistry.registerAlias("JNDI", JndiDataSourceFactory.class);
  typeAliasRegistry.registerAlias("POOLED", PooledDataSourceFactory.class);
  typeAliasRegistry.registerAlias("UNPOOLED", UnpooledDataSourceFactory.class);

  typeAliasRegistry.registerAlias("PERPETUAL", PerpetualCache.class);
  typeAliasRegistry.registerAlias("FIFO", FifoCache.class);
  typeAliasRegistry.registerAlias("LRU", LruCache.class);
  typeAliasRegistry.registerAlias("SOFT", SoftCache.class);
  typeAliasRegistry.registerAlias("WEAK", WeakCache.class);

  typeAliasRegistry.registerAlias("DB_VENDOR", VendorDatabaseIdProvider.class);

  typeAliasRegistry.registerAlias("XML", XMLLanguageDriver.class);
  typeAliasRegistry.registerAlias("RAW", RawLanguageDriver.class);

  typeAliasRegistry.registerAlias("SLF4J", Slf4jImpl.class);
  typeAliasRegistry.registerAlias("COMMONS_LOGGING", JakartaCommonsLoggingImpl.class);
  typeAliasRegistry.registerAlias("LOG4J", Log4jImpl.class);
  typeAliasRegistry.registerAlias("LOG4J2", Log4j2Impl.class);
  typeAliasRegistry.registerAlias("JDK_LOGGING", Jdk14LoggingImpl.class);
  typeAliasRegistry.registerAlias("STDOUT_LOGGING", StdOutImpl.class);
  typeAliasRegistry.registerAlias("NO_LOGGING", NoLoggingImpl.class);

  typeAliasRegistry.registerAlias("CGLIB", CglibProxyFactory.class);
  typeAliasRegistry.registerAlias("JAVASSIST", JavassistProxyFactory.class);

  languageRegistry.setDefaultDriverClass(XMLLanguageDriver.class);
  languageRegistry.register(RawLanguageDriver.class);
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:35,代码来源:Configuration.java


示例14: Configuration

import org.apache.ibatis.cache.decorators.LruCache; //导入依赖的package包/类
public Configuration() {
//事务类型
  typeAliasRegistry.registerAlias("JDBC", JdbcTransactionFactory.class);
  typeAliasRegistry.registerAlias("MANAGED", ManagedTransactionFactory.class);
  //数据源与连接池类型
  typeAliasRegistry.registerAlias("JNDI", JndiDataSourceFactory.class);
  typeAliasRegistry.registerAlias("POOLED", PooledDataSourceFactory.class);
  typeAliasRegistry.registerAlias("UNPOOLED", UnpooledDataSourceFactory.class);

  typeAliasRegistry.registerAlias("PERPETUAL", PerpetualCache.class);
  typeAliasRegistry.registerAlias("FIFO", FifoCache.class);
  typeAliasRegistry.registerAlias("LRU", LruCache.class);
  typeAliasRegistry.registerAlias("SOFT", SoftCache.class);
  typeAliasRegistry.registerAlias("WEAK", WeakCache.class);

  typeAliasRegistry.registerAlias("DB_VENDOR", VendorDatabaseIdProvider.class);

  typeAliasRegistry.registerAlias("XML", XMLLanguageDriver.class);
  typeAliasRegistry.registerAlias("RAW", RawLanguageDriver.class);

  typeAliasRegistry.registerAlias("SLF4J", Slf4jImpl.class);
  typeAliasRegistry.registerAlias("COMMONS_LOGGING", JakartaCommonsLoggingImpl.class);
  typeAliasRegistry.registerAlias("LOG4J", Log4jImpl.class);
  typeAliasRegistry.registerAlias("LOG4J2", Log4j2Impl.class);
  typeAliasRegistry.registerAlias("JDK_LOGGING", Jdk14LoggingImpl.class);
  typeAliasRegistry.registerAlias("STDOUT_LOGGING", StdOutImpl.class);
  typeAliasRegistry.registerAlias("NO_LOGGING", NoLoggingImpl.class);

  typeAliasRegistry.registerAlias("CGLIB", CglibProxyFactory.class);
  typeAliasRegistry.registerAlias("JAVASSIST", JavassistProxyFactory.class);

  languageRegistry.setDefaultDriverClass(XMLLanguageDriver.class);
  languageRegistry.register(RawLanguageDriver.class);
}
 
开发者ID:toulezu,项目名称:play,代码行数:35,代码来源:Configuration.java


示例15: test_LruCache

import org.apache.ibatis.cache.decorators.LruCache; //导入依赖的package包/类
@Test
public void test_LruCache() {
	LruCache lruCache = new LruCache(new PerpetualCache("test_LruCache"));
	lruCache.setSize(2);
	assertThat(lruCache.getSize(), equalTo(0));

	lruCache.putObject("name", "doctor");
	lruCache.putObject("age", 2000);
	lruCache.putObject("age", 3000);
	lruCache.putObject("age", 29000);
	lruCache.putObject("url", "https://github.com/doctorwho1986");

	assertThat(lruCache.getSize(), equalTo(2));
	assertThat(lruCache.getObject("name"), equalTo(null));
}
 
开发者ID:sdcuike,项目名称:spring4-2015,代码行数:16,代码来源:LruCachePractice.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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