net.sf.ehcache.Cache.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(180)

本文整理了Java中net.sf.ehcache.Cache.<init>()方法的一些代码示例,展示了Cache.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.<init>()方法的具体详情如下:
包路径:net.sf.ehcache.Cache
类名称:Cache
方法名:<init>

Cache.<init>介绍

[英]1.7.0 Constructor

The net.sf.ehcache.config.ConfigurationFactory and clients can create these.

A client can specify their own settings here and pass the Cache object into CacheManager#addCache to specify parameters other than the defaults.

Only the CacheManager can initialise them.
[中]1.7.0构造函数
网。旧金山。ehcache。配置。ConfigurationFactory和客户端可以创建这些。
客户端可以在此处指定自己的设置,并将缓存对象传递到CacheManager#addCache中,以指定默认值以外的参数。
只有CacheManager可以初始化它们。

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * Create a raw Cache object based on the configuration of this FactoryBean.
 */
protected Cache createCache() {
  return new Cache(this);
}

代码示例来源:origin: org.springframework/spring-context-support

/**
 * Create a raw Cache object based on the configuration of this FactoryBean.
 */
protected Cache createCache() {
  return new Cache(this);
}

代码示例来源:origin: stackoverflow.com

private static void createCacheForOkHTTP() {
  Cache cache = null;
  cache = new Cache(getDirectory(), 1024 * 1024 * 10);
  okHttpClient.setCache(cache);
}

// returns the file to store cached details
private File getDirectory() {
  return new File(“location”);
}

代码示例来源:origin: stackoverflow.com

CacheManager cacheManager = CacheManager.getInstance();
int oneDay = 24 * 60 * 60;
Cache memoryOnlyCache = new Cache("name", 200, false, false, oneDay, oneDay);
cacheManager.addCache(memoryOnlyCache);

代码示例来源:origin: stackoverflow.com

import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;

public class InitializationListener implements ServletContextListener {    
  @Override
  public void contextInitialized(ServletContextEvent sce) {
    ServletContext ctx = sce.getServletContext();
    CacheManager singletonManager = CacheManager.create();
    Cache memoryOnlyCache = new Cache("dbCache", 100, false, true, 86400,86400);
    singletonManager.addCache(memoryOnlyCache);
    cache = singletonManager.getCache("dbCache");       
    ctx.setAttribute("dbCache", cache );           
  }
}

代码示例来源:origin: gocd/gocd

@Bean(name = "goCache")
public GoCache createCache() {
  CacheManager cacheManager = CacheManager.newInstance(new Configuration().name(getClass().getName()));
  Cache cache = new Cache(cacheConfiguration);
  cacheManager.addCache(cache);
  return new GoCache(cache, transactionSynchronizationManager);
}

代码示例来源:origin: gocd/gocd

private static Ehcache createCacheIfRequired() {
  final CacheManager instance = CacheManager.newInstance(new Configuration().name(CachingSubjectDnX509PrincipalExtractor.class.getName()));
  synchronized (instance) {
    if (!instance.cacheExists(CACHE_NAME)) {
      instance.addCache(new Cache(cacheConfiguration()));
    }
    return instance.getCache(CACHE_NAME);
  }
}

代码示例来源:origin: gocd/gocd

private static Ehcache createCacheIfRequired(String cacheName) {
  final CacheManager instance = CacheManager.newInstance(new Configuration().name(cacheName));
  synchronized (instance) {
    if (!instance.cacheExists(cacheName)) {
      instance.addCache(new net.sf.ehcache.Cache(cacheConfiguration(cacheName)));
    }
    return instance.getCache(cacheName);
  }
}

代码示例来源:origin: gocd/gocd

private static Ehcache createCacheIfRequired(String cacheName) {
  final CacheManager instance = CacheManager.newInstance(new Configuration().name(cacheName));
  synchronized (instance) {
    if (!instance.cacheExists(cacheName)) {
      instance.addCache(new Cache(cacheConfiguration(cacheName)));
    }
    return instance.getCache(cacheName);
  }
}

代码示例来源:origin: spring-projects/spring-security

@BeforeClass
public static void initCacheManaer() {
  cacheManager = CacheManager.create();
  cacheManager.addCache(new Cache("ehcacheusercachetests", 500, false, false, 30,
      30));
}

代码示例来源:origin: spring-projects/spring-security

@BeforeClass
public static void initCacheManaer() {
  cacheManager = CacheManager.create();
  cacheManager.addCache(new Cache("basiclookuptestcache", 500, false, false, 30, 30));
}

代码示例来源:origin: spring-projects/spring-security

@BeforeClass
public static void initCacheManaer() {
  cacheManager = CacheManager.create();
  cacheManager.addCache(new Cache("castickets", 500, false, false, 30, 30));
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

private synchronized Cache getHeap() {
  if (heap == null) {
    if (CacheManager.getInstance().cacheExists("hydrated-cache")) {
      heap = CacheManager.getInstance().getCache("hydrated-cache");
    } else {
      CacheConfiguration config = new CacheConfiguration("hydrated-cache", 0).eternal(true).overflowToDisk(false).maxElementsInMemory(100000);
      Cache cache = new Cache(config);
      CacheManager.create().addCache(cache);
      heap = cache;
    }
  }
  return heap;
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

private synchronized Cache getHeap() {
  if (offHeap == null) {
    if (CacheManager.getInstance().cacheExists("hydrated-offheap-cache")) {
      offHeap = CacheManager.getInstance().getCache("hydrated-offheap-cache");
    } else {
      CacheConfiguration config = new CacheConfiguration("hydrated-offheap-cache", 500).eternal(true).overflowToOffHeap(true).maxMemoryOffHeap("1400M");
      Cache cache = new Cache(config);
      CacheManager.create().addCache(cache);
      offHeap = cache;
    }
  }
  return offHeap;
}

代码示例来源:origin: apache/kylin

new Cache(new CacheConfiguration("test", 0).//

代码示例来源:origin: spring-projects/spring-framework

@Before
public void setup() {
  cacheManager = new CacheManager(new Configuration().name("EhCacheCacheTests")
      .defaultCache(new CacheConfiguration("default", 100)));
  nativeCache = new net.sf.ehcache.Cache(new CacheConfiguration(CACHE_NAME, 100));
  cacheManager.addCache(nativeCache);
  cache = new EhCacheCache(nativeCache);
}

代码示例来源:origin: stackoverflow.com

int cacheSize = 10 * 1024 * 1024; // 10 MiB
File cacheDir = new File(context.getCacheDir(), "HttpCache");
Cache cache = new Cache(cacheDir, cacheSize);
OkHttpClient client = new OkHttpClient.Builder()
  .cache(cache)
  .build();

代码示例来源:origin: gravitee-io/gravitee-gateway

@Bean
public Cache cache() {
  CacheManager cacheManager = cacheManager();
  Cache apiKeyCache = cacheManager.getCache(CACHE_NAME);
  if (apiKeyCache == null) {
    LOGGER.warn("EHCache cache for " + CACHE_NAME + " not found. Fallback to default EHCache configuration");
    CacheConfiguration cacheConfiguration = new CacheConfiguration(CACHE_NAME, 1000);
    cacheManager.addCache(new Cache(cacheConfiguration));
  }
  return cacheManager.getCache(CACHE_NAME);
}

代码示例来源:origin: gravitee-io/gravitee-gateway

@Bean
public Cache cache() {
  CacheManager cacheManager = cacheManager();
  Cache apiKeyCache = cacheManager.getCache(API_KEY_CACHE_NAME);
  if (apiKeyCache == null) {
    LOGGER.warn("EHCache cache for apikey not found. Fallback to default EHCache configuration");
    CacheConfiguration cacheConfiguration = new CacheConfiguration(API_KEY_CACHE_NAME, 1000);
    cacheManager.addCache(new Cache(cacheConfiguration));
  }
  return cacheManager.getCache(API_KEY_CACHE_NAME);
}

代码示例来源:origin: net.sf.ehcache/ehcache

/**
 * Create a cache given a cache configuration
 *
 * @param cacheConfiguration
 */
final Ehcache createCache(CacheConfiguration cacheConfiguration) {        
  CacheConfiguration configClone = cacheConfiguration.clone();
  
  // make sure all caches use the same classloader that the CacheManager is configured to use
  configClone.setClassLoader(configuration.getClassLoader());
  
  Ehcache cache = new Cache(configClone, null, null);
  cache = applyCacheExceptionHandler(configClone, cache);
  return cache;
}

相关文章

微信公众号

最新文章

更多

Cache类方法