xwhyz
xwhyz

Reputation: 1514

Spring + Hibernate web application - When to use cache?

I'm building java web application which in future can generate a lot of traffic.

All in all it uses some quite simple queries to the database but still some kind of cache may be necessary to keep low latency and to prevent high database access rate.

Shall I bother with cache from the start? is it necessity? Is it hard to implement or use some open source solutions on existing queries and how such cache will know when database state changed?

Upvotes: 0

Views: 150

Answers (1)

Angular University
Angular University

Reputation: 43087

It all depends on how much traffic you expect, do you have some estimate of the max volume or the number of users?

Most of the times you don't need to worry about the cache from the beginning and can add later a hibernate second level cache later on.

You can start the development without a cache configured, then add it later on by choosing a cache provider and plug it as second level cache provider. EHCache is a frequent choice.

You can then annotate your entities with @Cache with different strategies, for example read only, etc.

Upvotes: 1

Related Questions