Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[Codemash] Caching Made "Bootiful"!

[Codemash] Caching Made "Bootiful"!

Needing more performance from your Java applications? Is latency causing you stress? Repetitive loading of the data in applications, burning CPU time, taxing I/O / disk access? Too many applications caching the same data sets pushing the limits of your data management and application architecture? If so, take a look at JCache! This code-driven session demonstrates how to integrate Hazelcast Distributed Caches into your Spring or Java EE applications. Adding a bunch of annotations to a method can achieve an orders-of-magnitude speed improvement in applications with high-latency.

Viktor Gamov

January 12, 2017
Tweet

More Decks by Viktor Gamov

Other Decks in Technology

Transcript

  1. • Performance • Offload expensive parts of your architecture •

    Scale up – get the most out of one machine • Scale out – add more capacity with more machines • Usually very fast and easy to apply Cache is good for…
  2. © 2017 Hazelcast Inc. @gamussa #codemash #jcache #hazelcast #springboot 0.

    Inception public class SpringwebinarApplication { public static interface CityService { public String getCity(); } @Bean public CityService getService() { return new CityService() { @Override public String getCity() { // slow code goes here! return result; } }; } }
  3. © 2017 Hazelcast Inc. @gamussa #codemash #jcache #hazelcast #springboot 1.

    Enable Caching import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.EnableCaching; @SpringBootApplication @EnableCaching public class SpringwebinarApplication { public static interface CityService { @Cacheable("city") public String getCity(); } @Bean public CityService getService() { return new CityService() { @Override public String getCity() { // slow code goes here! return result; } }; } }
  4. © 2017 Hazelcast Inc. @gamussa #codemash #jcache #hazelcast #springboot 2.

    Enable Distributed Caching import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.EnableCaching; @SpringBootApplication @EnableCaching public class SpringwebinarApplication { public static interface CityService { @Cacheable("city") public String getCity(); } @Bean public CityService getService() { return new CityService() { @Override public String getCity() { // slow code goes here! return result; } }; } @Bean public HazelcastInstance getInstance() { // return Hazelcast.newHazelcastInstance(); return HazelcastClient.newHazelcastClient(); } }
  5. © 2017 Hazelcast Inc. @gamussa #codemash #jcache #hazelcast #springboot 3.

    Embrace the standards – Enable JCache import javax.cache.annotation.CacheResult; import org.springframework.cache.annotation.EnableCaching; @SpringBootApplication @EnableCaching public class SpringwebinarApplication { public static interface CityService { @CacheResult(cacheName = "city") public String getCity(); } @Bean public CityService getService() { return new CityService() { @Override public String getCity() { // slow code goes here! return result; } }; } }