Guest User

Untitled

a guest
Jan 17th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. CacheConfiguration cc = new CacheConfiguration();
  2.  
  3. cc.setName("mycache");
  4. cc.setCacheMode(CacheMode.PARTITIONED);
  5. cc.setOnheapCacheEnabled(true);
  6. cc.setEvictionPolicy(new LruEvictionPolicy(5));
  7.  
  8. IgniteConfiguration cfg = new IgniteConfiguration();
  9. cfg.setCacheConfiguration(cc);
  10.  
  11. Ignite ignite = Ignition.start(cfg);
  12.  
  13. IgniteCache<String,String> cache = ignite.getOrCreateCache(cc);
  14.  
  15. for(int i=0;i<10;i++){
  16. cache.put("k"+i,"val-"+i);
  17. }
  18.  
  19. Thread.sleep(1000);
  20.  
  21. for(int i=0;i<10;i++) {
  22. System.out.println(cache.get("k"+i));
  23. }
  24.  
  25. System.out.println("============================== " + cache.metrics().getSize());
Add Comment
Please, Sign In to add comment