本文整理匯總了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();
}
示例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();
}
示例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();
}
示例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();
}
}
}