Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Spring 5 Design Patterns

You're reading from   Spring 5 Design Patterns Master efficient application development with patterns such as proxy, singleton, the template method, and more

Arrow left icon
Product type Paperback
Published in Oct 2017
Publisher Packt
ISBN-13 9781788299459
Length 396 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Dinesh Rajput Dinesh Rajput
Author Profile Icon Dinesh Rajput
Dinesh Rajput
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Getting Started with Spring Framework 5.0 and Design Patterns 2. Overview of GOF Design Patterns - Core Design Patterns FREE CHAPTER 3. Consideration of Structural and Behavioral Patterns 4. Wiring Beans using the Dependency Injection Pattern 5. Understanding the Bean Life Cycle and Used Patterns 6. Spring Aspect Oriented Programming with Proxy and Decorator pattern 7. Accessing a Database with Spring and JDBC Template Patterns 8. Accessing Database with Spring ORM and Transactions Implementing Patterns 9. Improving Application Performance Using Caching Patterns 10. Implementing the MVC Pattern in a Web Application using Spring 11. Implementing Reactive Design Patterns 12. Implementing Concurrency Patterns

Third-party cache implementations


Spring's SimpleCacheManager is ok for testing, but has no cache control options (overflow, eviction). So we have to use third-party alternatives like the following:

  • Terracotta's EhCache
  • Google's Guava and Caffeine
  • Pivotal's Gemfire

Let's see one of the configurations of third-party cache managers.

Ehcache-based cache

Ehcache is one of the most popular cache providers. Spring allows you to integrate with Ehcache by configuring EhCacheCacheManager in the application. Take for example, the following Java configuration:

    @Bean 
    public CacheManager cacheManager(CacheManager ehCache) { 
      EhCacheCacheManager cmgr = new EhCacheCacheManager(); 
      cmgr.setCacheManager(ehCache); 
      return cmgr; 
    } 
    @Bean  
    public EhCacheManagerFactoryBean ehCacheManagerFactoryBean() { 
      EhCacheManagerFactoryBean eh = new EhCacheManagerFactoryBean(); 
      eh.setConfigLocation(new  
      ClassPathResource("resources/ehcache.xml")); 
      return eh; ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime