2. Who is this guy?
Senior Solutions Architect @ Hazelcast
Java Developer for 17 years
@dbrimley
In Memory Data Grids for 8 years
Worked for Investment Banks
Started out coding Basic on a Commodore Vic-20
My fav computer was my old BBC Model B
Long suffering Spurs fan.
HSBC, Nomura, Credit Suisse, BZW, RBoS
Oracle Coherence 4 Years
Pivotal Gemfire 4 Years
David Brimley
Runs HUGL (Hazelcast User Group London)
Low latency trading systems
3. What we’ll cover…
• Why Caching?
• Introduction to JCache.
• Using Caches.
• Entry Processors.
• Listeners.
• Annotations.
• Missing Bits.
• Questions.
6. Why Caching?
The Speed Factor (Memory .v. Disk)
L1 cache reference 0.5 ns
Branch mispredict 5.0 ns
L2 cache reference 7.0 ns
Mutex lock/unlock 25.00 ns
Main memory reference 100.00 ns
Compress 1k bytes with ZupZ 3,000.00 ns
Send 1k bytes over 1Gpbs network 10,000.00 ns 0.01 ms
Read 4k randomly from SSD 150,000.00 ns 0.15 ms
Read 1 MB sequentially from memory 250,000.00 ns 0.25 ms
Round trip within same datacenter 500,000.00 ns 0.50 ms
Read 1 MB sequentially from SSD 1,000,000.00 ns 1.00 ms
Disk seek 10,000,000.00 ns 10.00 ms
Read 1 MB sequentially from disk 20,000,000.00 ns 20.00 ms
Send packet CA->Netherlands->CA 150,000,000.00 ns 150.00 ms
https://gist.github.com/jboner/2841832
7. Why Caching?
Graph of Memory Prices Decreasing with Time (1957-2014)
http://www.jcmit.com/mem2014.htm
The Cost Factor
8. Why Caching?
Lots of Use Cases
Slow Database
HTTP Proxy
Browser
Persistence Framework
Disk
Application
Hard to scale Database
Lots of Cache Types
Local Cache
Data Grid
Document Store
JPA Second Level
JPA First Level
10. Introduction to JCache
• Caching for the Java Platform
• Produced via the JCP / JSR107
• Ratified March 2014
• 10 years in the making.
• Works with SDK.
• Spec Leads: Greg Luck, Brian Oliver
11. java.util.Map (Java 6/7)
Key-Value Based API
Supports Atomic Updates
Entries Don’t Expire
Entries Aren’t Evicted
Entries Stored On-Heap
Store-By-Reference
https://gist.github.com/jboner/2841832
Introduction to JCache
Map .v. Cache
javax.cache.Cache (Java 6)
Key-Value Based API
Supports Atomic Updates
Entries May Expire
Entries May Be Evicted
Entries Stored Anyware (ie: topologies)
Store-By-Value and Store-By-Reference
Supports Integration (ie: Loaders/Writers)
Supports Observation (ie: Listeners
Entry Processors
Statistics
13. Introduction to JCache
• JCP Project
http://jcp.org/en/jsr/detail?id=107
• Source Code
https://github.com/jsr107
• Forum
https://groups.google.com/forum/?
fromgroups#!forum/jsr107
14. JSR107 TCK Compliant Vendors
Introduction to JCache
https://jcp.org/aboutJava/communityprocess/implementations/jsr107/index.html
I pity the fool that claims
to support JCache without
TCK compliance
As of 5th March 2015
15. Introduction to JCache
Something to remember when comparing vendors of
distributed caches…
Do NOT Benchmark
with a single
instance!
24. Listeners
Callbacks for events in Cache
• Follows Observer Pattern
• Interface per event type
• Created, Updated, Removed, Expired
• Iterations of Events passed back
• MutableCacheEntryListenerConfiguration
36. HAZELCAST
• Free London Training
• Hazelcast User Group
• Visit our Booth
Visit our Booth
5th Floor
Get Free Training (Canary Wharf, Thursday 12th March)
http://hazelcast.com/events/
Join the Hazelcast User Group London (HUGL)
http://www.meetup.com/Hazelcast-User-Group-London-HUGL/
Download Hazelcast, the leading open source IMDG
http://www.hazelcast.org