• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to store a cache in the Tomcat's Context using Spring?

 
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I may not be asking the question exactly right, but is it possible to store a cache (HashTable, or something similar) in Tomcat's memory that would be outside any running webapps?

Since we're creating a bunch of webapps that would all benefit from a cache, we want that cache to be outside any of the web apps so it would persist.

This is probably simple to do in Spring, but I was just wondering how practical it is and how you would remove the cache when needed without restarting Tomcat.

Any suggestions on how to implement this?

Thanks in advance.

- mike
 
Ranch Hand
Posts: 119
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe this link is a beginning to you:

Caching in Tomcat – SOLVED!
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Caching in Tomcat


That talks mostly about web caching (as opposed to caching in general used by web apps). My preferred approach would be to do that outside of Tomcat, using something like Redis.
 
Edson Cezar
Ranch Hand
Posts: 119
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:

Caching in Tomcat


That talks mostly about web caching (as opposed to caching in general used by web apps). My preferred approach would be to do that outside of Tomcat, using something like Redis.




I didn't know about Redis, Thanks !
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not completely sure I am following but I don't think Spring offers anything along the lines of a global cache shared among all web applications running on a server. If it needs to persist Ulf might be on the right track with something like Redis, or you could look at ehcache or similar as well.

Spring does offer a cache abstraction through the use of the @Cacheable annotation but it still needs to be backed by the cache storage which out of the box can be either ehcache or a concurrent map.

More on that here:
http://docs.spring.io/spring/docs/3.2.6.BUILD-SNAPSHOT/spring-framework-reference/htmlsingle/#cache-annotations
 
To get a wish, you need a genie. To get a genie, you need a lamp. To get a lamp, you need a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic