SlideShare a Scribd company logo
Distributed Caching
with Java
Kasun Gajasinghe
Senior Software Engineer
WSO2
● What & Why for (Distributed) Caching
● Different types of Caches
● Cache access patterns
● Java JCache specification
● Demo
● Q&A
Agenda
(... but why do I
want to Cache?)
O O O
source: http://no7scramblecross.blogspot.com/2009/04/speaking-of-cats.html
Caching? … Distributed?
Gotcha!!
source: http://matome.naver.jp/odai/2140238539583350401/2140238875587055003
● Application performance - get around
bottlenecks arising from using data that is
expensive to retrieve
○ DB or web service
○ data that is hard to calculate
○ monetary aspects
Why software Caching
● improve the response times by reducing data
access latency
● avoid cost of repeatedly creating objects
● reduces IO overhead
Caching
● limited memory size
● consistency - consistency between cached
data vs actual data
● durability - cache expiration/invalidation
● scalability
Caching considerations
Types of caches
● local cache
● replicated cache
● distributed cache
Local Cache
● Local Cache a cache that is local to
(completely contained within) a particular
cluster node
Local Cache - example
Local Cache - with TTL
Local Cache
Pros:
● simplicity
● performance
● no serialization/deserialization overhead
Cons:
● not fault-tolerant
● scalability
Replicated cache
● a cache that replicates its data to all cluster
nodes
GET in replicated cache
Each cluster node (JVM) accesses the data from its own
memory, i.e. a local read.
PUT in replicated cache
Pushing the new version of the data to all other cluster
nodes
Replicated Cache
Pros:
● best read performance
● fault–tolerant
● linear performance scalability for reads
Cons:
● poor write performance
● memory consumption
● additional network load
● poor and limited scalability for writes
Distributed Cache
a cache that partitions its data among all
cluster nodes
GET in Distributed Cache
Access often must go over the network to another cluster
node
Resolving known limitation of replicated cache:
PUT in Distributed Cache
PUT in Distributed Cache
● the data is being sent to a primary cluster node
and a backup cluster node if backup count is 1
● modifications to the cache are not considered
complete until all backups have acknowledged
receipt of the modification, i.e. slight
performance penalty
● such overhead guarantees that data consistency
is maintained and no data is lost
Failover in Distributed Cache
Failover involves promoting backup data to be
primary storage.
Distributed Cache
Pros:
● linear performance scalability for reads and writes
● fault–tolerant
Cons:
● increased latency of reads (due to network round-trip
and serialization/deserialization expenses)
Cache Access Patterns
● cache aside
● read-through
● write-through
Cache Aside Pattern
● application is responsible of reading and writing to the
storage.
● cache doesn’t interact with storage
● the cache is ‘kept aside’ as a faster and more scalable in-
memory data store
Read-through/Write-through
● application treats the cache as the main data
store, and reads/writes data from/to it
● cache is responsible to read/write the data
into the actual storage.
Java JCache specification
● Standard Java Caching API
● javax.cache.*
● Implementation can be local or distributed
JCache API
● javax.cache.Cache
● javax.cache.CacheManager
● javax.cache.spi.CachingProvider
JCache API
JCache API - Annotations
• Use the cache
JCache API - Annotations
• Put into the cache
JCache API - Annotations
• Remove from the cache
javax.cache.expiry.
● AccessedExpiryPolicy: Expires after a given set of time measured from creation of the cache entry, the expiry timeout is
updated on accessing the key.
● CreatedExpiryPolicy: Expires after a given set of time measured from creation of the cache entry, the expiry timeout is
never updated.
● EternalExpiryPolicy: Never expires, this is the default behavior, similar to ExpiryPolicy to be set to null.
● ModifiedExpiryPolicy
● TouchedExpiryPolicy
JCache API - Expiry Policies
JCache implementations
• Hazelcast
• Oracle Coherence
• Pivotal Gemfire
• Ehcache
• Infinispan
• Gridgain/Ignite
• Couchbase
Q&A
THANK YOU!
1. http://docs.hazelcast.org/docs/latest/manual/html-single/hazelcast-
documentation.html#hazelcast-jcache
2. https://spring.io/blog/2014/04/14/cache-abstraction-jcache-jsr-107-
annotations-support
References

More Related Content

Viewers also liked (12)

PPTX
Caching In Java- Best Practises and Pitfalls
HARIHARAN ANANTHARAMAN
 
PDF
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
elliando dias
 
PPTX
From cache to in-memory data grid. Introduction to Hazelcast.
Taras Matyashovsky
 
PPTX
Jug Lugano - Scale over the limits
Davide Carnevali
 
PPTX
Data Locality, Latency and Caching: JSR-107 and the new Java JCACHE Standard
Ben Cotton
 
KEY
Redis overview for Software Architecture Forum
Christopher Spring
 
PPTX
Caching solutions with Redis
George Platon
 
PDF
Managing user's data with Spring Session
David Gómez García
 
PDF
Distributed applications using Hazelcast
Taras Matyashovsky
 
PPTX
From distributed caches to in-memory data grids
Max Alexejev
 
PDF
JCache Using JCache
日本Javaユーザーグループ
 
PPTX
Real time Analytics with Apache Kafka and Apache Spark
Rahul Jain
 
Caching In Java- Best Practises and Pitfalls
HARIHARAN ANANTHARAMAN
 
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
elliando dias
 
From cache to in-memory data grid. Introduction to Hazelcast.
Taras Matyashovsky
 
Jug Lugano - Scale over the limits
Davide Carnevali
 
Data Locality, Latency and Caching: JSR-107 and the new Java JCACHE Standard
Ben Cotton
 
Redis overview for Software Architecture Forum
Christopher Spring
 
Caching solutions with Redis
George Platon
 
Managing user's data with Spring Session
David Gómez García
 
Distributed applications using Hazelcast
Taras Matyashovsky
 
From distributed caches to in-memory data grids
Max Alexejev
 
Real time Analytics with Apache Kafka and Apache Spark
Rahul Jain
 

Similar to Distributed caching with java JCache (20)

PDF
Caching principles-solutions
pmanvi
 
PPTX
IMC Summit 2016 Breakout - Greg Luck - How to Speed Up Your Application Using...
In-Memory Computing Summit
 
PDF
Caching and JCache with Greg Luck 18.02.16
Comsysto Reply GmbH
 
PDF
Spring One 2 GX 2014 - CACHING WITH SPRING: ADVANCED TOPICS AND BEST PRACTICES
Michael Plöd
 
PDF
JSR107 State of the Union JavaOne 2013
Hazelcast
 
PDF
Caching 101: Caching on the JVM (and beyond)
Louis Jacomet
 
PDF
JCache - It's finally here
Hazelcast
 
PDF
JCache (JSR107) - QCon London 2015 & JBCNConf Barcelona 2015
David Brimley
 
PDF
Overview of the ehcache
HyeonSeok Choi
 
PDF
Caching 101: sur la JVM et au delà
Louis Jacomet
 
PDF
Ehcache Architecture, Features And Usage Patterns
Eduardo Pelegri-Llopart
 
PPTX
CREAM - That Conference Austin - January 2024.pptx
Matthew Groves
 
PPTX
Think Distributed: The Hazelcast Way
Rahul Gupta
 
PDF
In-memory No SQL- GIDS2014
Hazelcast
 
PDF
Using JCache to speed up your apps
Vassilis Bekiaris
 
PPTX
Cache Rules Everything Around Me - Momentum - October 2022.pptx
Matthew Groves
 
PPT
Caching for J2ee Enterprise Applications
Debajani Mohanty
 
PDF
Caching reboot: javax.cache & Ehcache 3
Louis Jacomet
 
PPTX
Selecting the right cache framework
Mohammed Fazuluddin
 
PPTX
Distributed caching and computing v3.7
Rahul Gupta
 
Caching principles-solutions
pmanvi
 
IMC Summit 2016 Breakout - Greg Luck - How to Speed Up Your Application Using...
In-Memory Computing Summit
 
Caching and JCache with Greg Luck 18.02.16
Comsysto Reply GmbH
 
Spring One 2 GX 2014 - CACHING WITH SPRING: ADVANCED TOPICS AND BEST PRACTICES
Michael Plöd
 
JSR107 State of the Union JavaOne 2013
Hazelcast
 
Caching 101: Caching on the JVM (and beyond)
Louis Jacomet
 
JCache - It's finally here
Hazelcast
 
JCache (JSR107) - QCon London 2015 & JBCNConf Barcelona 2015
David Brimley
 
Overview of the ehcache
HyeonSeok Choi
 
Caching 101: sur la JVM et au delà
Louis Jacomet
 
Ehcache Architecture, Features And Usage Patterns
Eduardo Pelegri-Llopart
 
CREAM - That Conference Austin - January 2024.pptx
Matthew Groves
 
Think Distributed: The Hazelcast Way
Rahul Gupta
 
In-memory No SQL- GIDS2014
Hazelcast
 
Using JCache to speed up your apps
Vassilis Bekiaris
 
Cache Rules Everything Around Me - Momentum - October 2022.pptx
Matthew Groves
 
Caching for J2ee Enterprise Applications
Debajani Mohanty
 
Caching reboot: javax.cache & Ehcache 3
Louis Jacomet
 
Selecting the right cache framework
Mohammed Fazuluddin
 
Distributed caching and computing v3.7
Rahul Gupta
 
Ad

More from Kasun Gajasinghe (7)

PDF
Building Services with WSO2 Microservices framework for Java and WSO2 AS
Kasun Gajasinghe
 
PDF
Building Services with WSO2 Microservices framework for Java and WSO2 AS
Kasun Gajasinghe
 
PDF
[WSO2] Deployment Synchronizer for Deployment Artifact Synchronization Betwee...
Kasun Gajasinghe
 
PDF
Siddhi CEP Engine
Kasun Gajasinghe
 
PPT
Scheduler Activations - Effective Kernel Support for the User-Level Managemen...
Kasun Gajasinghe
 
PPT
Survey on Frequent Pattern Mining on Graph Data - Slides
Kasun Gajasinghe
 
PDF
Google Summer of Code 2011 Sinhalese flyer
Kasun Gajasinghe
 
Building Services with WSO2 Microservices framework for Java and WSO2 AS
Kasun Gajasinghe
 
Building Services with WSO2 Microservices framework for Java and WSO2 AS
Kasun Gajasinghe
 
[WSO2] Deployment Synchronizer for Deployment Artifact Synchronization Betwee...
Kasun Gajasinghe
 
Siddhi CEP Engine
Kasun Gajasinghe
 
Scheduler Activations - Effective Kernel Support for the User-Level Managemen...
Kasun Gajasinghe
 
Survey on Frequent Pattern Mining on Graph Data - Slides
Kasun Gajasinghe
 
Google Summer of Code 2011 Sinhalese flyer
Kasun Gajasinghe
 
Ad

Recently uploaded (20)

PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Tally software_Introduction_Presentation
AditiBansal54083
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 

Distributed caching with java JCache