What's difference between hibernate caching and Spring framework cache?

前端 未结 2 1359
感情败类
感情败类 2021-02-16 00:04

I have an application where I get the data from database (using hibernate). I want to load the cache (per user) with database state once per day and use the cache instead.

2条回答
  •  无人及你
    2021-02-16 00:18

    Starting with Hibernate cache is a more prudent decision in my view, especially because the two don't exclude each other. In terms of performance Spring cache can offer you more, its much higher in the stack, you can cache business results (basically more than you can with hibernate's second level cache).

    However one outstanding distinction is clearing the cache. With Spring cache you need to clear explicitly, while the hibernate cache is maintained automatically if your inserts, updates and deletions go through hibernate's framework.

    In the context of the projects that I'm involved, using hibernate's second level cache is assumed, a default almost. Spring cache we use for the data that are much more static in nature.

提交回复
热议问题