This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring cache ?

 
Abhay Agarwal
Ranch Hand
Posts: 1375
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Does Spring framework has its own caching framework ?

I need to create an object in Spring MVC application and want to save it in cache.
And then later on, i want to get it from cache and read its values .

Thanks
Abhay
 
Sagar Rohankar
Ranch Hand
Posts: 2904
1
Java Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be I didn't get your question correctly, but if you want to read that object later, then try initializing object lazily.

Caching things come when you want to access some "heavy" object often from your application.

You also like to see the Spring Cache abstraction, but it support method caching. Read for further details: http://static.springsource.org/spring/docs/3.1.0.M1/spring-framework-reference/html/cache.html
 
Craig Walls
author
Ranch Hand
Posts: 363
8
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abhay Agarwal wrote:Does Spring framework has its own caching framework ?


Spring 3.1 has a caching abstraction, allowing you to annotate methods with @Cacheable and @CacheEvict to control the caching of the values returned from those methods. But the caching abstract is intended to be used with a separate caching framework such as Hibernate caching or Gemfire.
 
Sujoy Choudhury
Ranch Hand
Posts: 136
Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Spring 3.1 has a caching abstraction, allowing you to annotate methods with @Cacheable and @CacheEvict to control the caching of the values returned from those methods. But the caching abstract is intended to be used with a separate caching framework such as Hibernate caching or Gemfire.


Nice to know about these new annotations. Have you discussed in your book about these in depth?
 
Craig Walls
author
Ranch Hand
Posts: 363
8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I don't cover those in the book because they're new in Spring 3.1 (which is still at milestone 2) and the book only covers up through Spring 3.0. By the time those annotations were added to the framework, the book was already well on it's way through the production process.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does it support ehcache ?
 
Sagar Rohankar
Ranch Hand
Posts: 2904
1
Java Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pradeep bhatt wrote:Does it support ehcache ?
Yes
http://static.springsource.org/spring/docs/3.1.0.M1/spring-framework-reference/html/cache.html wrote:Note that just like other services in Spring Framework, the caching service is an abstraction (not a cache implementation) and requires the use of an actual storage to store the cache data - that is, the abstraction frees the developer from having to write the caching logic but does not provide the actual stores. There are two integrations available out of the box, for JDK java.util.concurrent.ConcurrentMap and Ehcache
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic