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


Java DefaultCacheManager.getCache方法代码示例

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


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

示例1: main

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
public static void main(String[] args) {
   ConfigurationBuilder builder = new ConfigurationBuilder();
   builder.indexing().index(Index.ALL)
      .addProperty("default.directory_provider", "ram")
      .addProperty("lucene_version", "LUCENE_CURRENT");
   // Construct a simple local cache manager with default configuration
   DefaultCacheManager cacheManager = new DefaultCacheManager(builder.build());
   // Obtain the default cache
   Cache<String, Person> cache = cacheManager.getCache();
   // Store some entries
   cache.put("person1", new Person("William", "Shakespeare"));
   cache.put("person2", new Person("William", "Wordsworth"));
   cache.put("person3", new Person("John", "Milton"));
   // Obtain a query factory for the cache
   QueryFactory queryFactory = Search.getQueryFactory(cache);
   // Construct a query
   Query query = queryFactory.from(Person.class).having("name").eq("William").toBuilder().build();
   // Execute the query
   List<Person> matches = query.list();
   // List the results
   matches.forEach(person -> System.out.printf("Match: %s", person));
   // Stop the cache manager and release all resources
   cacheManager.stop();
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:25,代码来源:InfinispanQuery.java

示例2: main

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
   // Setup up a clustered cache manager
   GlobalConfigurationBuilder global = GlobalConfigurationBuilder.defaultClusteredBuilder();
   // Make the default cache a replicated synchronous one
   ConfigurationBuilder builder = new ConfigurationBuilder();
   builder.clustering().cacheMode(CacheMode.REPL_SYNC);
   // Initialize the cache manager
   DefaultCacheManager cacheManager = new DefaultCacheManager(global.build(), builder.build());
   // Obtain the default cache
   Cache<String, String> cache = cacheManager.getCache();
   // Store the current node address in some random keys
   for(int i=0; i < 10; i++) {
      cache.put(UUID.randomUUID().toString(), cacheManager.getNodeAddress());
   }
   // Display the current cache contents for the whole cluster
   cache.entrySet().forEach(entry -> System.out.printf("%s = %s\n", entry.getKey(), entry.getValue()));
   // Display the current cache contents for this node
   cache.getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP)
      .entrySet().forEach(entry -> System.out.printf("%s = %s\n", entry.getKey(), entry.getValue()));
   // Stop the cache manager and release all resources
   cacheManager.stop();
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:23,代码来源:InfinispanReplicated.java

示例3: main

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
public static void main(String[] args) {
   // Construct a simple local cache manager with default configuration
   DefaultCacheManager cacheManager = new DefaultCacheManager();
   // Define local cache configuration
   cacheManager.defineConfiguration("local", new ConfigurationBuilder().build());
   // Obtain the local cache
   Cache<String, String> cache = cacheManager.getCache("local");
   // Store some values
   int range = 10;
   IntStream.range(0, range).boxed().forEach(i -> cache.put(i + "-key", i + "-value"));
   // Map and reduce the keys
   int result = cache.keySet().stream()
      .map((Serializable & Function<String, Integer>) e -> Integer.valueOf(e.substring(0, e.indexOf("-"))))
           .collect(CacheCollectors.serializableCollector(() -> Collectors.summingInt(i -> i.intValue())));
   System.out.printf("Result = %d\n", result);
   // Stop the cache manager and release all resources
   cacheManager.stop();
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:19,代码来源:InfinispanStreams.java

示例4: main

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
public static void main(String[] args) {
   // Construct a simple local cache manager with default configuration
   DefaultCacheManager cacheManager = new DefaultCacheManager();
   // Define local cache configuration
   cacheManager.defineConfiguration("local", new ConfigurationBuilder().build());
   // Obtain the local cache
   Cache<String, String> cache = cacheManager.getCache("local");
   // Register a listener
   cache.addListener(new MyListener());
   // Store some values
   cache.put("key1", "value1");
   cache.put("key2", "value2");
   cache.put("key1", "newValue");
   // Stop the cache manager and release all resources
   cacheManager.stop();
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:17,代码来源:InfinispanListen.java

示例5: main

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
public static void main(String[] args) {
   // Setup up a clustered cache manager
   GlobalConfigurationBuilder global = GlobalConfigurationBuilder.defaultClusteredBuilder();
   // Make the default cache a distributed one
   ConfigurationBuilder builder = new ConfigurationBuilder();
   builder.clustering().cacheMode(CacheMode.DIST_SYNC);
   // Initialize the cache manager
   DefaultCacheManager cacheManager = new DefaultCacheManager(global.build(), builder.build());
   // Obtain the default cache
   Cache<String, String> cache = cacheManager.getCache();
   // Create a distributed executor service using the distributed cache to determine the nodes on which to run
   DefaultExecutorService executorService = new DefaultExecutorService(cache);
   // Submit a job to all nodes
   List<Future<Integer>> results = executorService.submitEverywhere((Callable & Serializable) () -> new Random().nextInt());
   // Print out the results
   results.forEach(s -> {
      try {
         System.out.printf("%s\n", s.get(100, TimeUnit.MILLISECONDS));
      } catch (Exception e) {
      }
   });
   // Shuts down the cache manager and all associated resources
   cacheManager.stop();
   System.exit(0);
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:26,代码来源:InfinispanDistExec.java

示例6: main

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
   // Setup up a clustered cache manager
   GlobalConfigurationBuilder global = GlobalConfigurationBuilder.defaultClusteredBuilder();
   // Make the default cache a distributed synchronous one
   ConfigurationBuilder builder = new ConfigurationBuilder();
   builder.clustering().cacheMode(CacheMode.DIST_SYNC);
   // Initialize the cache manager
   DefaultCacheManager cacheManager = new DefaultCacheManager(global.build(), builder.build());
   // Obtain the default cache
   Cache<String, String> cache = cacheManager.getCache();
   // Store the current node address in some random keys
   for(int i=0; i < 10; i++) {
      cache.put(UUID.randomUUID().toString(), cacheManager.getNodeAddress());
   }
   // Display the current cache contents for the whole cluster
   cache.entrySet().forEach(entry -> System.out.printf("%s = %s\n", entry.getKey(), entry.getValue()));
   // Display the current cache contents for this node
   cache.getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP)
      .entrySet().forEach(entry -> System.out.printf("%s = %s\n", entry.getKey(), entry.getValue()));
   // Stop the cache manager and release all resources
   cacheManager.stop();
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:23,代码来源:InfinispanDistributed.java

示例7: initialize

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
/**
 * 초기화
 * @param configFile
 * @param cacheName
 * @param loginCacheName
 * @throws IOException
 */
@Override
public void initialize(String configFile, String cacheName, String loginCacheName)
        throws IOException {
    try {
        StringUtils.isNotNull("configFile", configFile);

        cacheManager = new DefaultCacheManager(configFile);

        this.cacheName = cacheName;
        this.loginCacheName = loginCacheName;

        cache = cacheManager.getCache(cacheName);
        loginCache = cacheManager.getCache(loginCacheName);

        waitForConnectionReady();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:opennaru-dev,项目名称:khan-session,代码行数:27,代码来源:InfinispanLibrayImpl.java

示例8: main

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException {
	
     
      // Initialize the cache manager
	DefaultCacheManager cacheManager = new DefaultCacheManager("config/beosbank-infinispan.xml");
      // Obtain the default cache
      Cache<Long, MoneyTransfert> cache = cacheManager.getCache("beosbank-dist");
      
      
	// Obtain the remote cache
	cache.addListener(new DatagridListener());
	// Create a Money Transfer Object from XML Message using BeaoIO API
	try {
		BeosBankCacheUtils.loadEntries(cache,inputFileNames);
		// Inspect the cache .
		System.out.println(cache.size());
		Thread.sleep(2000);
		cache.get(5l);
		System.out.println("Cache content after 2 sec");
		//Current node content
		printCacheContent(cache);
		
		Thread.sleep(1000);
		System.out.println("Cache content after 3 sec");
		printCacheContent(cache);
		
		Thread.sleep(3000);
		System.out.println("Cache content after 6 sec");
		printCacheContent(cache);
		
		// Stop the cache
		cache.stop();

	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}
 
开发者ID:PacktPublishing,项目名称:JBoss-Developers-Guide,代码行数:40,代码来源:ExpirationXmlConfiguration.java

示例9: main

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException {
	
      //Configuration
	ConfigurationBuilder builder = new ConfigurationBuilder();
	builder
		.eviction()
		.strategy(EvictionStrategy.LRU)
		.type(EvictionType.COUNT)
		.size(3)
		;
      // Initialize the cache manager
	DefaultCacheManager cacheManager = new DefaultCacheManager(builder.build());
    // Obtain the default cache
    Cache<Long, MoneyTransfert> cache = cacheManager.getCache("beosbank-dist");
      
	// Obtain the remote cache
	cache.addListener(new DatagridListener());
	// Create a Money Transfer Object from XML Message using BeaoIO API
	try {
		BeosBankCacheUtils.loadEntries(cache,inputFileNames);

		// Inspect the cache .
		System.out.println(cache.size());
		System.out.println(cache.get(3l));
		
		//Current node content
		cache.getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP)
        .entrySet().forEach(entry -> System.out.printf("%s = %s\n", entry.getKey(), entry.getValue().getDescription()));
		
		// Stop the cache
		cache.stop();

	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}
 
开发者ID:PacktPublishing,项目名称:JBoss-Developers-Guide,代码行数:39,代码来源:EvictionDemo.java

示例10: init

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
private void init() throws Exception
{
    log.info(this + " initializing ...");

    //DefaultCacheManager cm = configureProgrammatically();
    DefaultCacheManager cm = configureDeclaratively();


    Cache sc = cm.getCache("SOURCE-CACHE");
    caches.put("SOURCE-CACHE", sc);

    Cache dc = cm.getCache("DESTINATION-CACHE");
    caches.put("DESTINATION-CACHE", dc);
}
 
开发者ID:NovaOrdis,项目名称:playground,代码行数:15,代码来源:ProcessingNode.java

示例11: main

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
   // Define the default cache to be transactional
   ConfigurationBuilder builder = new ConfigurationBuilder();
   builder.transaction().transactionMode(TransactionMode.TRANSACTIONAL);
   // Construct a local cache manager using the configuration we have defined
   DefaultCacheManager cacheManager = new DefaultCacheManager(builder.build());
   // Obtain the default cache
   Cache<String, String> cache = cacheManager.getCache();
   // Obtain the transaction manager
   TransactionManager transactionManager = cache.getAdvancedCache().getTransactionManager();
   // Perform some operations within a transaction and commit it
   transactionManager.begin();
   cache.put("key1", "value1");
   cache.put("key2", "value2");
   transactionManager.commit();
   // Display the current cache contents
   System.out.printf("key1 = %s\nkey2 = %s\n", cache.get("key1"), cache.get("key2"));
   // Perform some operations within a transaction and roll it back
   transactionManager.begin();
   cache.put("key1", "value3");
   cache.put("key2", "value4");
   transactionManager.rollback();
   // Display the current cache contents
   System.out.printf("key1 = %s\nkey2 = %s\n", cache.get("key1"), cache.get("key2"));
   // Stop the cache manager and release all resources
   cacheManager.stop();
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:28,代码来源:InfinispanTx.java

示例12: main

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
public static void main(String[] args) {
   // Construct a simple local cache manager with default configuration
   DefaultCacheManager cacheManager = new DefaultCacheManager();
   // Define local cache configuration
   cacheManager.defineConfiguration("local", new ConfigurationBuilder().build());
   // Obtain the local cache
   Cache<String, String> cache = cacheManager.getCache("local");
   // Store a value
   cache.put("key", "value");
   // Retrieve the value and print it out
   System.out.printf("key = %s\n", cache.get("key"));
   // Stop the cache manager and release all resources
   cacheManager.stop();
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:15,代码来源:InfinispanMap.java

示例13: main

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
public static void main(String[] args) throws UnknownHostException {
    //Configure Infinispan to use default transport and Kubernetes configuration
    GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().transport()
            .defaultTransport()
            .addProperty("configurationFile", "default-configs/default-jgroups-kubernetes.xml")
            .build();

    //Each node generates events, so we don't want to consume all memory available.
    //Let's limit number of entries to 100 and use sync mode
    ConfigurationBuilder cacheConfiguration = new ConfigurationBuilder();
    cacheConfiguration.clustering().cacheMode(CacheMode.DIST_SYNC);
    cacheConfiguration.eviction().strategy(EvictionStrategy.LRU).size(100);

    DefaultCacheManager cacheManager = new DefaultCacheManager(globalConfig, cacheConfiguration.build());
    Cache<String, String> cache = cacheManager.getCache();
    cache.addListener(new MyListener());

    //Each cluster member will update its own entry in the cache
    String hostname = Inet4Address.getLocalHost().getHostName();
    ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
    scheduler.scheduleAtFixedRate(() -> cache.put(hostname, Instant.now().toString()), 0, 2, TimeUnit.SECONDS);

    try {
        //This container will operate for an hour and then it will die
        TimeUnit.HOURS.sleep(1);
    } catch (InterruptedException e) {
        scheduler.shutdown();
        cacheManager.stop();
    }
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:31,代码来源:InfinispanKubernetes.java

示例14: initialize

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
public void initialize(Configuration config) {
GlobalConfigurationBuilder global = new GlobalConfigurationBuilder();
global.globalJmxStatistics().allowDuplicateDomains(true);
manager = new DefaultCacheManager(global.build());
ConfigurationBuilder builder = new ConfigurationBuilder();
   builder.persistence()
          .addStore(SoftIndexFileStoreConfigurationBuilder.class)
          .indexLocation(config.getDataDir()+"/index")
          .dataLocation(config.getDataDir()+"/data");
      manager.defineConfiguration("raccovery-cache", builder.build(global.build()));
   cache = manager.getCache("raccovery-cache");
   LOG.info("Starting persistence layer");
  }
 
开发者ID:dlmarion,项目名称:raccovery,代码行数:14,代码来源:InfinispanPersistence.java

示例15: setUp

import org.infinispan.manager.DefaultCacheManager; //导入方法依赖的package包/类
@Before
public void setUp() {
    _cacheMgr = new DefaultCacheManager(new GlobalConfigurationBuilder()
        .transport().defaultTransport().build());
    
    _cacheMgr.defineConfiguration("test-cache", 
            new ConfigurationBuilder().invocationBatching().enable().build());
    Cache<String, String> cache = _cacheMgr.getCache("test-cache");
    _registry = new InfinispanRegistry(cache);
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:11,代码来源:InfinispanRegistryTest.java


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