Devoxx – Improve the performance of your Spring app

Leave a comment

This talk by Costin Leau was about the new caching features in Spring 3.1.

After going over some problems you can face when caching (stale data, thrashing, distributed caches) and different caching patterns he introduced the declarative caching of Spring 3.1.

It uses AOP and can be declared on methods by adding the @Cacheable annotation. This annotation caches a method’s return value using it’s parameters as the key although this can be customised.


The @CacheEvict annotation invalidates the cache:

You can also use your own stereotype annotations. Instead of spreading @Cacheable everywhere:

Spring is not a cache provider itself. You plug in your own cache provider (ehcache, JBoss Cache, etc).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.