1

Normally I have used memcached to speed up the web (or non web) applications I work with. Unfortunately I am in a situation in which I have no way to install memcache (this is not a technical constraint, it is just bureaucracy).

So I was considering if I could just use some cache system that lives within the same jvm where I deploy my web application. I check it out and found JCS (http://commons.apache.org/proper/commons-jcs/) which seems like a good fit.

What I need is:

  • Key-value store
  • Ability to set a ttl to the values (that is, they get automatically deleted)
  • Keys will be strings, values could be pretty much anything, but possibly a string representation of an object
  • The ability to define the max amount of memory to be used by this cache system.
  • The cache is not going to have many items into it, I do not need anything massive.

What I do not need

  • Sharding

Would JCS be a good approach?

UPDATE

Finally we end up using guava-cache and it works fine so far, there are a couple of limitations (for example it does not seem to be possible to have different expiration times for different keys within the same cache), but for the use case, it is fine so far.

Juan Antonio Gomez Moriano
  • 13,103
  • 10
  • 47
  • 65
  • 1
    I worked with [guava-cache](https://code.google.com/p/guava-libraries/wiki/CachesExplained), and it worked well for my usecase (it satisfies your requirements as well) – jmj Jul 14 '14 at 04:25
  • @JigarJoshi Does guava let you limit the amount of memory used? I though it only had a *max number of items* limitation. – Robby Cornelissen Jul 14 '14 at 04:29
  • 1
    Possibly. You might also consider [Ehcache](https://en.wikipedia.org/wiki/Ehcache). – Elliott Frisch Jul 14 '14 at 04:35
  • @Robby you are right about it, I assumed OP wants on number of elements – jmj Jul 14 '14 at 04:36

0 Answers0