61
www.hazelcast.com @noctarius2k /** * Gimme Caching * The JCache Way */

Gimme Caching - The JCache Way

Embed Size (px)

Citation preview

Page 1: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

/** * Gimme Caching * The JCache Way */

Page 2: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

Interactive!

Page 3: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

Page 4: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

Disclaimer# A fatal error has been detected by the Java Runtime Environment: # # SIGSEGV (0xb) at pc=0x00002aaaaaf6d9c3, pid=2185, tid=1086892352 # # JRE version: 6.0_21-b06 # Java VM: Java HotSpot(TM) 64-Bit Server VM (17.0-b16 mixed mode linux-amd64 ) # # An error report file with more information is saved as: # /path/to/hs_err_pid2185.log # # This presentation may include certain forward-looking statements and projections provided by the Company. Any such # statements and projections reflect various estimates and assumptions by the Company concerning anticipated # results. These statements involve risks, uncertainties and assumptions and are based on the current estimates and # assumptions of the management of the Company as of the date of this presentation and are subject to uncertainty and # changes. No representations or warranties are made by the Company as to the accuracy of any such statements or # projections. Whether or not any such forward-looking statements or projections are in fact achieved will depend upon # future events some of which are not within the control of the Company. Accordingly, actual results may vary from the # projected results and such variations may be material. Statements contained herein describing documents and # agreements are summaries only and such summaries are qualified in their entirety by reference to such documents # and agreements.

Page 5: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

Who’s that dude?

• Chris(toph) Engelbert • Twitter fanatic: @noctarius2k • Weird 9+ Java-Years • Performance, GC, Fairytales • Apache Committer • Gaming, Travel Management, …

Page 6: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

• Chris(toph) Engelbert • Twitter fanatic: @noctarius2k • Weird 9+ Java-Years • Performance, GC, Fairytales • Apache Committer • Gaming, Travel Management, …

The www.hazelcast.ninja

Who’s that dude?

Page 7: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

… What is Caching?OOO( )

Page 8: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

Collect, store …

Page 9: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

…access fast when necessary!…access fast when necessary!

Page 10: Gimme Caching - The JCache Way

www.hazelcast.com

Fast Delivery

Page 11: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

‘In-Memory Caching’

L1 Cache Reference L2 Cache Reference Main Memory Reference 1K send over 1 Gbps Network 4K read from SSD Seek on Spinning Disk Send Packet CA->AMS->CA

0.5 ns 7 ns

100 ns 10,000 ns

150,000 ns 10,000,000 ns

150,000,000 ns

0.01 ms 0.15 ms

10 ms 150 ms

Page 12: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

Evolution of:- Memory-Price- Memory-Size

Page 13: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

Caches

Page 14: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

http://gadizmo.com/roll-your-own-with-the-ham-dogger.php

Roll Your Own!Caches Are Simple

Page 15: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

Caches Are Simple!public class Cache<K, V> { private final Map<K, V> cache = new CHM<>();

public void put(K key, V value) { cache.put(key, value); }

public V get(K key) { return cache.get(key); } }

Page 16: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

Even With TTL!

Page 17: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

And Auto-Cleanup

Page 18: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

What Is Wrong?

Page 19: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

What Is Wrong?

O(n)5 mio

Entries

Page 20: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

It was a trap!

Page 21: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

Distributed Caching!

Page 22: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

Page 23: Gimme Caching - The JCache Way

www.hazelcast.com

Data Partitioning

Page 24: Gimme Caching - The JCache Way

www.hazelcast.com

Data Partitioning

Page 25: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

JCache?

Page 26: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

A Java Caching Standard!

Page 27: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

No need to ## care aboutProprietary Solutions

anymore!

Page 28: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

“Vendor Independent”

Page 29: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

http://technoodling.net/mili-power-crystal-battery-pack-review/

Terracotta /EHcache

OracleCoherence

Infinispan

JavaCollections

API

Hazelcast

JCache

Custom

Page 30: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

JCache Impementations

Page 31: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

JCache Impementations

Hazelcast

Page 32: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

JCache Impementations

Hazelcast Ehcache

Page 33: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

JCache Impementations

Hazelcast EhcacheInfinispan

Page 34: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

JCache Impementations

Hazelcast

Apache IgniteEhcache

Infinispan

Page 35: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

JCache Impementations

Hazelcast Coherence

Apache IgniteEhcache

Infinispan

Page 36: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

JCache Impementations

Hazelcast CoherenceInfinispanApache Ignite How Dare You Are To Call You JCache?

Ehcache

Page 37: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

Success!Feels like

Page 38: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

Demo Time

Page 39: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

// Ask the JCache API for implementationsCachingProvider cachingProvider = Caching.getCachingProvider();

Demo Time

Page 40: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

// Ask the JCache API for implementationsCachingProvider cachingProvider = Caching.getCachingProvider();

Demo Time

Caching.getCachingProvider(myClassLoader); Caching.getCachingProvider("c.h.c.CachingProvider");

Page 41: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

// Ask the JCache API for implementationsCachingProvider cachingProvider = Caching.getCachingProvider();

Demo Time

Caching.getCachingProvider(myClassLoader); Caching.getCachingProvider("c.h.c.CachingProvider");

Page 42: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

// Ask the JCache API for implementationsCachingProvider cachingProvider = Caching.getCachingProvider(); // Build cache scope, multiple can exist CacheManager cacheManager = cachingProvider.getCacheManager();

Demo Time

Page 43: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

// Ask the JCache API for implementationsCachingProvider cachingProvider = Caching.getCachingProvider(); // Build cache scope, multiple can exist CacheManager cacheManager = cachingProvider.getCacheManager();

Demo Time

cachingProvider.getCacheManager(myURI, myClassLoader)

Page 44: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

// Ask the JCache API for implementationsCachingProvider cachingProvider = Caching.getCachingProvider(); // Build cache scope, multiple can exist CacheManager cacheManager = cachingProvider.getCacheManager();// Configure the new cache Configuration<Integer, String> configuration = new MutableConfiguration<Integer, String>() .setTypes(Integer.class, String.class);

Demo Time

Page 45: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

// Ask the JCache API for implementationsCachingProvider cachingProvider = Caching.getCachingProvider(); // Build cache scope, multiple can exist CacheManager cacheManager = cachingProvider.getCacheManager();// Configure the new cache Configuration<Integer, String> configuration = new MutableConfiguration<Integer, String>() .setTypes(Integer.class, String.class); // Create the actual cache Cache<Integer, String> cache = cacheManager.createCache("name", configuration);

Demo Time

Page 46: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

// Ask the JCache API for implementationsCachingProvider cachingProvider = Caching.getCachingProvider(); // Build cache scope, multiple can exist CacheManager cacheManager = cachingProvider.getCacheManager();// Configure the new cache Configuration<Integer, String> configuration = new MutableConfiguration<Integer, String>() .setTypes(Integer.class, String.class); // Get the actual cache Cache<Integer, String> cache = cacheManager.getCache("name", Integer.class, String.class);

Demo Time

Page 47: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

// Configure the new cache Configuration<Integer, String> configuration = …;// Get the actual cache Cache<Integer, String> cache = cacheManager.getCache(…);

if (cache == null) { try { cache = cacheManager.createCache("name", configuration); } catch (CacheException e) { cache = cacheManager.getCache(…); } }

Demo Time

Page 48: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

<hazelcast xmlns="…"> <cache name="named"> <key-type="java.lang.Integer"/> <key-type="java.lang.String"/> </cache> </hazelcast>

Demo Time

Page 49: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

<hazelcast xmlns="…"> <cache name="named"> <key-type="java.lang.Integer"/> <key-type="java.lang.String"/> </cache> </hazelcast>

Demo Time

Page 50: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

<hazelcast xmlns="…"> <cache name="named"> <key-type="java.lang.Integer"/> <key-type="java.lang.String"/> </cache> </hazelcast>

Demo Time

Page 51: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

<hazelcast xmlns="…"> <cache name="named"> <key-type="java.lang.Integer"/> <key-type="java.lang.String"/> </cache> </hazelcast>

Demo Time

Page 52: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

// Ask the JCache API for implementationsCachingProvider cachingProvider = Caching.getCachingProvider(); // Build cache scope, multiple can exist CacheManager cacheManager = cachingProvider.getCacheManager();// Configure the new cache Configuration<Integer, String> configuration = new MutableConfiguration<Integer, String>() .setTypes(Integer.class, String.class); // Get the actual cache Cache<Integer, String> cache = cacheManager.getCache("name", Integer.class, String.class);

Demo Time

Page 53: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

I told you:Easy Peasy!

Page 54: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

Quick Shameless Plug :)Hazelcast!

Page 55: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

Hazelcast in 5 Facts• Java Collections API• Java Concurrency API

• Transparent Data Distribution• Drop-In Replacement

• Disruptively Simple(c) Rod Johnson (@springrod)

Page 56: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

Time to be Happy!

Page 57: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

Time to be Happy!

Apache License 2

Page 58: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

Time to be Happy!

www.hazelcast.org

Page 59: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

You can do it!

Page 60: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

Thank You!Any Questions?

@noctarius2k http://www.sourceprojects.org

http://github.com/noctarius

@hazelcast http://www.hazelcast.com http://www.hazelcast.org

http://github.com/hazelcast

Page 61: Gimme Caching - The JCache Way

www.hazelcast.com@noctarius2k

Thank You!Any Questions?

@noctarius2k http://www.sourceprojects.org

http://github.com/noctarius

@hazelcast http://www.hazelcast.com http://www.hazelcast.org

http://github.com/hazelcast

Free Hazelcast T-Shirthttp://bit.ly/tshirtcast