Book Image

Getting Started with Hazelcast, Second Edition

By : Matthew Johns
Book Image

Getting Started with Hazelcast, Second Edition

By: Matthew Johns

Overview of this book

Table of Contents (19 chapters)
Getting Started with Hazelcast Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Cacheable methods with the Spring cache


While the caching layer provided as part of Hibernate unlocks easy and convenient caching for high-frequency or high-cost data, caching at a higher level, or more generally, method calls, can be expensive too.

Newer versions of the Spring framework (since version 3.1) feature the ability to transparently cache method calls and their returned results through the use of the com.hazelcast.spring.cache.HazelcastCacheManager class, and its registration as a Spring cache manager.

<cache:annotation-driven cache-manager="cacheManager" />

<bean id="cacheManager"
  class="com.hazelcast.spring.cache.HazelcastCacheManager">

  <constructor-arg ref="hzInstance"/>
</bean>

With this in place, we can then mark appropriate methods as @Cacheable, and where required, use @CacheEvict to trigger cache invalidations.