SlideShare a Scribd company logo
Using JCache to
speed up your apps
Vassilis Bekiaris

Software Engineer, Hazelcast

@karbonized1
About me
• First computer:

Amstrad 6128 green screen
• Favorite languages I never

used in production: Ada, CLISP
• Freelancer (-2008)
• Software Architect, Team Leader, Jack of all Trades
(2008-2016)
• Software Engineer, Hazelcast (2016-)
Outline
• Caching basics
• Introducing JSR-107 (JCache)
• Using JCache
Why cache?
• Performance
• Offload expensive or non-scalable parts of your
architecture
• Buffer against load variability
• Usually fast and easy to apply
When to use caching
• When applications use the same data more than
once
• When fetching or producing the data again is
expensive
Caches in RAM and beyond
NVRAM/Flash/SSD

(serialized form)
Local Storage
Heap

(Objects)
Opaque to 

GC in RAM

(serialized form)
<100 ns
< 100ns

+deserialization time
2
500
1,000+
Latency
Size (GB)
Network Storage
< 50us

+deserialization time
< 140us for 1Gbps

< 70us for 10Gbps/40Gbps

+deserialization time
20,000+Scaleout across the network

(serialized form)
Diagram: Greg Luck
Implementation patterns
• Cache aside
App Cache
System
of
Record
(1) get
(2) null
(3) fetch (4) value
(5) put
Implementation patterns
• Cache through
App Cache
System
of
Record
(1) get
(2) fetch
(3) value
(4) value
Other implementation
considerations
• In-process
• Distributed
Introducing JSR-107
• The standard way to cache for Java applications
• One of the longest running JSRs
• Started in 2001
• JSR-107 1.0 final released in March 2014
• JSR-107 1.1 maintenance release (draft review
done, expected mid-December 2017)
• Target: Java SE 6+
JCache implementations
• Apache Ignite
• Blazing Cache
• cache2k
• Caffeine
• Coherence (Oracle)
• Ehcache
• Hazelcast
• Infinispan
• …

(https://jcp.org/aboutJava/communityprocess/implementations/jsr107/index.html)
java.util.Map
Key-Value Based API
Supports Atomic Updates
Entries Don’t Expire
Entries Aren’t Evicted
Entries Stored On-Heap
Store-By-Reference
javax.cache.Cache
Key-Value Based API
Supports Atomic Updates
Entries May Expire
Entries May Be Evicted
Entries Stored Anywhere (ie: topologies)
Store-By-Value and Store-By-Reference
Supports Integration (ie: Loaders / Writers)
Supports Observation (ie: Listeners)
Entry Processors
Statistics
Cache != Map
Cache now!
• Add javax.cache:cache-api:1.0.0 to your classpath
• Add an implementation
• Hello, world!
JCache API
• Caching
• “Service loader”: locates implementation, supplies CachingProvider(s)
• CachingProvider
• Creates & manages CacheManagers (per {URI, ClassLoader})
• CacheManager
• Manages Caches lifecycle
• Cache
• That’s what your app uses!
Entry processors
• Data transformations
• Computations
Listeners
• Caches are observable
• CacheEntryCreatedListener
• CacheEntryUpdatedListener
• CacheEntryRemovedListener
• CacheEntryExpiredListener
Cache Loader/Writer
• Integration with system of record
• Read-through, write-through
Annotations
• @CacheResult



@CachePut



@CacheRemove



@CacheRemoveAll
• JSR107 RI provides support for CDI, Spring &
Guice
Annotations
@CacheDefaults(cacheName = “users”)
class User {
@CacheResult
User getUser(long id);
@CachePut
void createUser(long id, @CacheValue User user);
@CacheRemove
User removeUser(long id);
…
}
Management & Statistics
• Via JMX
• Can be enabled/disabled at runtime
• CacheManager.enableStatistics(cacheName, true)
• CacheManager.enableManagement(cacheName, true)
Integrations
• Spring
• CDI
• Payara server
JSR-107 links
• 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
Sample code
• Sample project
• https://github.com/vbekiaris/jcache-demo
• Adding caching with JSR107 annotations to a
spring-boot sample:
• https://github.com/vbekiaris/spring-boot/tree/
jcache-jhug/add-caching-to-echoservice

More Related Content

PPT
Scaling MySQL using Fabric
PPTX
Big Data, Big Projects, Big Mistakes: How to Jumpstart and Deliver with Success
PDF
Azure Virtual Machines Deployment Scenarios
PPTX
Ansible for large scale deployment
PDF
Big App Workloads on Microsoft Azure - TechEd Europe 2014
PDF
Mongo db world 2014 nyc mongodb on azure - tips tricks and examples
PDF
Tech Ed North America 2014 - Java on Azure
PDF
Webinar - DreamObjects/Ceph Case Study
Scaling MySQL using Fabric
Big Data, Big Projects, Big Mistakes: How to Jumpstart and Deliver with Success
Azure Virtual Machines Deployment Scenarios
Ansible for large scale deployment
Big App Workloads on Microsoft Azure - TechEd Europe 2014
Mongo db world 2014 nyc mongodb on azure - tips tricks and examples
Tech Ed North America 2014 - Java on Azure
Webinar - DreamObjects/Ceph Case Study

What's hot (19)

PPTX
Google cloud platform (for those who know Microsoft Azure)
PPTX
Redis Labs and SQL Server
PDF
Tech ED 2014 Running Oracle Databases and Application Servers on Azurev1
PDF
The future of node
PDF
Modern MySQL Monitoring and Dashboards.
PDF
Eric Moreau - Samedi SQL - Backup dans Azure et BD hybrides
PDF
MySQL 5.7 what's new
PDF
MySQL Cloud Service Deep Dive
PPTX
Azure PaaS databases
PDF
Scaling Pinterest
PPTX
ACS & vSphere Draft
PDF
Using MySQL in Automated Testing
PDF
Managing multi tenant resource toward Hive 2.0
PPTX
Sql Server 2014 Hybrid Cloud
PPTX
Doing More with Postgres - Yesterday's Vision Becomes Today's Reality
 
PPTX
October 2014 HUG : Oozie HA
PPTX
Soaring through the Clouds - Oracle Fusion Middleware Partner Forum 2016
PDF
01 upgrade to my sql8
PDF
Getting started with Riak in the Cloud
Google cloud platform (for those who know Microsoft Azure)
Redis Labs and SQL Server
Tech ED 2014 Running Oracle Databases and Application Servers on Azurev1
The future of node
Modern MySQL Monitoring and Dashboards.
Eric Moreau - Samedi SQL - Backup dans Azure et BD hybrides
MySQL 5.7 what's new
MySQL Cloud Service Deep Dive
Azure PaaS databases
Scaling Pinterest
ACS & vSphere Draft
Using MySQL in Automated Testing
Managing multi tenant resource toward Hive 2.0
Sql Server 2014 Hybrid Cloud
Doing More with Postgres - Yesterday's Vision Becomes Today's Reality
 
October 2014 HUG : Oozie HA
Soaring through the Clouds - Oracle Fusion Middleware Partner Forum 2016
01 upgrade to my sql8
Getting started with Riak in the Cloud
Ad

Similar to Using JCache to speed up your apps (20)

PPTX
IMC Summit 2016 Breakout - Greg Luck - How to Speed Up Your Application Using...
PDF
Caching and JCache with Greg Luck 18.02.16
PDF
PDF
JCache - It's finally here
PDF
JCache (JSR107) - QCon London 2015 & JBCNConf Barcelona 2015
PDF
Caching reboot: javax.cache & Ehcache 3
PDF
Java Caching
PDF
Ehcache3 — JSR-107 on steroids
PDF
JCache is here. Say Goodbye to proprietary Caching APIs!
PDF
JCache is here. Say goodbye to proprietary Caching API's", jDays 2015 Speaker...
PDF
JSR107 State of the Union JavaOne 2013
PDF
Caching 101: Caching on the JVM (and beyond)
PDF
Ehcache 3 @ BruJUG
PDF
Ehcache 3: JSR-107 on steroids at Devoxx Morocco
PDF
Gimme Caching - The JCache Way
PDF
Gimme Caching - The JCache Way
PDF
Caching 101: sur la JVM et au delà
PDF
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
PDF
Distributed applications using Hazelcast
PDF
Java In-Process Caching - Performance, Progress and Pittfalls
IMC Summit 2016 Breakout - Greg Luck - How to Speed Up Your Application Using...
Caching and JCache with Greg Luck 18.02.16
JCache - It's finally here
JCache (JSR107) - QCon London 2015 & JBCNConf Barcelona 2015
Caching reboot: javax.cache & Ehcache 3
Java Caching
Ehcache3 — JSR-107 on steroids
JCache is here. Say Goodbye to proprietary Caching APIs!
JCache is here. Say goodbye to proprietary Caching API's", jDays 2015 Speaker...
JSR107 State of the Union JavaOne 2013
Caching 101: Caching on the JVM (and beyond)
Ehcache 3 @ BruJUG
Ehcache 3: JSR-107 on steroids at Devoxx Morocco
Gimme Caching - The JCache Way
Gimme Caching - The JCache Way
Caching 101: sur la JVM et au delà
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
Distributed applications using Hazelcast
Java In-Process Caching - Performance, Progress and Pittfalls
Ad

Recently uploaded (20)

PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
history of c programming in notes for students .pptx
PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
Transform Your Business with a Software ERP System
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
ai tools demonstartion for schools and inter college
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Essential Infomation Tech presentation.pptx
PPTX
Introduction to Artificial Intelligence
PDF
Nekopoi APK 2025 free lastest update
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
medical staffing services at VALiNTRY
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
System and Network Administraation Chapter 3
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
Design an Analysis of Algorithms I-SECS-1021-03
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
history of c programming in notes for students .pptx
How Creative Agencies Leverage Project Management Software.pdf
Transform Your Business with a Software ERP System
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
ai tools demonstartion for schools and inter college
Operating system designcfffgfgggggggvggggggggg
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Essential Infomation Tech presentation.pptx
Introduction to Artificial Intelligence
Nekopoi APK 2025 free lastest update
Design an Analysis of Algorithms II-SECS-1021-03
medical staffing services at VALiNTRY
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
System and Network Administraation Chapter 3
2025 Textile ERP Trends: SAP, Odoo & Oracle

Using JCache to speed up your apps

  • 1. Using JCache to speed up your apps Vassilis Bekiaris Software Engineer, Hazelcast @karbonized1
  • 2. About me • First computer:
 Amstrad 6128 green screen • Favorite languages I never
 used in production: Ada, CLISP • Freelancer (-2008) • Software Architect, Team Leader, Jack of all Trades (2008-2016) • Software Engineer, Hazelcast (2016-)
  • 3. Outline • Caching basics • Introducing JSR-107 (JCache) • Using JCache
  • 4. Why cache? • Performance • Offload expensive or non-scalable parts of your architecture • Buffer against load variability • Usually fast and easy to apply
  • 5. When to use caching • When applications use the same data more than once • When fetching or producing the data again is expensive
  • 6. Caches in RAM and beyond NVRAM/Flash/SSD
 (serialized form) Local Storage Heap
 (Objects) Opaque to 
 GC in RAM
 (serialized form) <100 ns < 100ns
 +deserialization time 2 500 1,000+ Latency Size (GB) Network Storage < 50us
 +deserialization time < 140us for 1Gbps
 < 70us for 10Gbps/40Gbps
 +deserialization time 20,000+Scaleout across the network
 (serialized form) Diagram: Greg Luck
  • 7. Implementation patterns • Cache aside App Cache System of Record (1) get (2) null (3) fetch (4) value (5) put
  • 8. Implementation patterns • Cache through App Cache System of Record (1) get (2) fetch (3) value (4) value
  • 10. Introducing JSR-107 • The standard way to cache for Java applications • One of the longest running JSRs • Started in 2001 • JSR-107 1.0 final released in March 2014 • JSR-107 1.1 maintenance release (draft review done, expected mid-December 2017) • Target: Java SE 6+
  • 11. JCache implementations • Apache Ignite • Blazing Cache • cache2k • Caffeine • Coherence (Oracle) • Ehcache • Hazelcast • Infinispan • …
 (https://jcp.org/aboutJava/communityprocess/implementations/jsr107/index.html)
  • 12. java.util.Map Key-Value Based API Supports Atomic Updates Entries Don’t Expire Entries Aren’t Evicted Entries Stored On-Heap Store-By-Reference javax.cache.Cache Key-Value Based API Supports Atomic Updates Entries May Expire Entries May Be Evicted Entries Stored Anywhere (ie: topologies) Store-By-Value and Store-By-Reference Supports Integration (ie: Loaders / Writers) Supports Observation (ie: Listeners) Entry Processors Statistics Cache != Map
  • 13. Cache now! • Add javax.cache:cache-api:1.0.0 to your classpath • Add an implementation • Hello, world!
  • 14. JCache API • Caching • “Service loader”: locates implementation, supplies CachingProvider(s) • CachingProvider • Creates & manages CacheManagers (per {URI, ClassLoader}) • CacheManager • Manages Caches lifecycle • Cache • That’s what your app uses!
  • 15. Entry processors • Data transformations • Computations
  • 16. Listeners • Caches are observable • CacheEntryCreatedListener • CacheEntryUpdatedListener • CacheEntryRemovedListener • CacheEntryExpiredListener
  • 17. Cache Loader/Writer • Integration with system of record • Read-through, write-through
  • 19. Annotations @CacheDefaults(cacheName = “users”) class User { @CacheResult User getUser(long id); @CachePut void createUser(long id, @CacheValue User user); @CacheRemove User removeUser(long id); … }
  • 20. Management & Statistics • Via JMX • Can be enabled/disabled at runtime • CacheManager.enableStatistics(cacheName, true) • CacheManager.enableManagement(cacheName, true)
  • 22. JSR-107 links • 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
  • 23. Sample code • Sample project • https://github.com/vbekiaris/jcache-demo • Adding caching with JSR107 annotations to a spring-boot sample: • https://github.com/vbekiaris/spring-boot/tree/ jcache-jhug/add-caching-to-echoservice