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


Java CacheManager.shutdown方法代码示例

本文整理汇总了Java中net.sf.ehcache.CacheManager.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Java CacheManager.shutdown方法的具体用法?Java CacheManager.shutdown怎么用?Java CacheManager.shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.ehcache.CacheManager的用法示例。


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

示例1: 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

示例2: testEhCacheTicketRegistryWithClearPass

import net.sf.ehcache.CacheManager; //导入方法依赖的package包/类
@Test
public void testEhCacheTicketRegistryWithClearPass() {
    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<String, String>();

    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:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:23,代码来源:TicketRegistryDecoratorTests.java

示例3: testEhcache

import net.sf.ehcache.CacheManager; //导入方法依赖的package包/类
@Test
public void testEhcache() {
    // Creating a CacheManager based on a specified configuration file.
    CacheManager manager = CacheManager.newInstance("src/main/resources/ehcache.xml");
    // obtains a Cache called sampleCache1, which has been preconfigured in the configuration file
    Cache cache = manager.getCache("sampleCache1");
    // puts an element into a cache
    Element element = new Element("key1", "哈哈");
    cache.put(element);
    //The following gets a NonSerializable value from an element with a key of key1.
    Object value = element.getObjectValue();
    System.out.println(value.toString());
    manager.shutdown();
}
 
开发者ID:Zephery,项目名称:newblog,代码行数:15,代码来源:TestEhcache.java

示例4: main

import net.sf.ehcache.CacheManager; //导入方法依赖的package包/类
/**
 * Run an ehcache based client, against the Terracotta Server
 *
 */
public static void main(String[] args) throws IOException {

  String terracottaServerUrl = System.getenv("TERRACOTTA_SERVER_URL");

  if(terracottaServerUrl == null || terracottaServerUrl.trim().equals("")) {
    System.out.println("The environment variable TERRACOTTA_SERVER_URL was not set; using terracotta:9510 as the cluster url.");
    terracottaServerUrl = "terracotta:9510";
  }

  System.out.println("**** Programmatically configure an instance, configured to connect to : " + terracottaServerUrl + " ****");

  Configuration managerConfiguration = new Configuration()
      .name("myCacheManager")
      .terracotta(new TerracottaClientConfiguration().url(terracottaServerUrl))
      .cache(new CacheConfiguration()
          .name("myCache")
          .maxEntriesLocalHeap(50)
          .copyOnRead(true)
          .eternal(true)
          .terracotta(new TerracottaConfiguration())
      );

  CacheManager manager = CacheManager.create(managerConfiguration);
  try {
    Cache myCache = manager.getCache("myCache");
    //myCache is now ready.

    Random random = new Random();
    if (myCache.getSize() > 0) {
      System.out.println("**** We found some data in the cache ! I guess some other client inserted data in BigMemory ! **** ");
    }
    System.out.println("**** Starting inserting / getting elements **** ");
    while (!Thread.currentThread().isInterrupted() && manager.getStatus() == Status.STATUS_ALIVE) {
      // indexes spread between 0 and 999
      int index = random.nextInt(1000);
      if (random.nextInt(10) < 3 && myCache.getSize() < 1000) {
        // put
        String value = new BigInteger(1024 * 128 * (1 + random.nextInt(10)), random).toString(16);
        System.out.println("Inserting at key  " + index + " String of size : " + value.length() + " bytes");
        myCache.put(new Element(index, value)); // construct a big string of 256k data
      } else {
        // get
        Element element = myCache.get(index);
        System.out.println("Getting key  " + index + (element == null ? ", that was a miss" : ", THAT WAS A HIT !"));
      }
      Thread.sleep(100);

    }
  } catch (InterruptedException e) {
    e.printStackTrace();
  } finally {
    if (manager != null) {
      manager.shutdown();
    }
  }
}
 
开发者ID:Terracotta-OSS,项目名称:docker,代码行数:61,代码来源:ClientDoingInsertionsAndRetrievals.java


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