0

I use ehcache as second level cache and I want to use it to store simple text messages and locales (They are stored in the DB). But those messages will never change, so there is no need to refresh the data.

Should I set a new cache with no expiration? Should I use my existing cache?

Bhavik Ambani
  • 6,557
  • 14
  • 55
  • 86
Ido Barash
  • 4,856
  • 11
  • 41
  • 78

1 Answers1

2

(They are stored in the DB). But those messages will never change, so there is no need to refresh the data.

Why even use ehcache at all ? Just code it in Java without any database access. for constants like that I use an Enum or read from a property file, which is loaded postconstruction. You could even read it from database one time instead of a proeprty file.

(and I bet those messages will change eventually ...)

NimChimpsky
  • 46,453
  • 60
  • 198
  • 311
  • actually I prefer your approach, but this application uses a legacy DB and it has all the messages in the DB. – Ido Barash Dec 16 '12 at 12:01
  • you can read form db and store in java without ehcache ... thats all you need to do. Ehcache provides additional functionality you don't require here. – NimChimpsky Dec 16 '12 at 12:04
  • OK, You saying that I should just store the messages in a normal MAP and manage it on my own? – Ido Barash Dec 16 '12 at 12:13
  • Yeah a hashmap or an enum sound good (but anything stored in memory, and thus not requiring db access - would achieve the same benefit), it doesn't take any management does it ? they never change ... – NimChimpsky Dec 16 '12 at 12:15