This presentation provides a comparison of types of caches highlighting the use of distributed caching. This is followed by an introduction to JCache API. Code samples are at [2].
This is the presentation I did at Java Colombo JUG. [2]
[1] https://github.com/kasunbg/jcache-samples
[2] http://www.meetup.com/java-colombo/events/223811796/
5. ● 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
6. ● improve the response times by reducing data
access latency
● avoid cost of repeatedly creating objects
● reduces IO overhead
Caching
7. ● limited memory size
● consistency - consistency between cached
data vs actual data
● durability - cache expiration/invalidation
● scalability
Caching considerations
20. 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
21. Failover in Distributed Cache
Failover involves promoting backup data to be
primary storage.
22. 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)
24. 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
31. JCache API - Annotations
• Remove from the cache
32. 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