Reaching critical masses with your application systems becomes harder every day. Caching helps to provide low latency and high availability over slow calculation, networks, databases and any other kind of external resource.
4. 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.
15. 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);
}
}
40. www.hazelcast.com@noctarius2k
// Ask the JCache API for implementations
CachingProvider cachingProvider = Caching.getCachingProvider();
Demo Time
Caching.getCachingProvider(myClassLoader);
Caching.getCachingProvider("c.h.c.CachingProvider");
41. www.hazelcast.com@noctarius2k
// Ask the JCache API for implementations
CachingProvider cachingProvider = Caching.getCachingProvider();
Demo Time
Caching.getCachingProvider(myClassLoader);
Caching.getCachingProvider("c.h.c.CachingProvider");
42. www.hazelcast.com@noctarius2k
// Ask the JCache API for implementations
CachingProvider cachingProvider = Caching.getCachingProvider();
// Build cache scope, multiple can exist
CacheManager cacheManager = cachingProvider.getCacheManager();
Demo Time
43. www.hazelcast.com@noctarius2k
// Ask the JCache API for implementations
CachingProvider cachingProvider = Caching.getCachingProvider();
// Build cache scope, multiple can exist
CacheManager cacheManager = cachingProvider.getCacheManager();
Demo Time
cachingProvider.getCacheManager(myURI, myClassLoader)
44. www.hazelcast.com@noctarius2k
// Ask the JCache API for implementations
CachingProvider 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
45. www.hazelcast.com@noctarius2k
// Ask the JCache API for implementations
CachingProvider 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
46. www.hazelcast.com@noctarius2k
// Ask the JCache API for implementations
CachingProvider 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
47. 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
52. www.hazelcast.com@noctarius2k
// Ask the JCache API for implementations
CachingProvider 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
55. 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)