Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
Bartender
Posts: 1752
17
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
I believe this link is a beginning to you:

Caching in Tomcat – SOLVED!
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
snakes are really good at eating slugs. And you wouldn't think it, but so are tiny ads:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic