I am developing one rest application with spring boot and mysql. Currently I am still in development phase, hence I have not enabled any caching as such. I future as the load increases, I will use memcached(as we already use memcached for other apps in our org) or redis to cache the resulsts of db queries. Right now I have not even enabled hibernate second level caching, so I am seeing too many db calls. I would like to enable caching preferably ehcache to reduce the db calls.
Mine is a rest api, currently we are running it in 3 pods in aws.
What sort of caching should I enable (not memcached or redis)
- Spring cache (ehcache)
- Hibernate second level cache
My main objective right now is to reduce number of db calls.
should I use only hibernate second level cache or spring cache ?
Here is my default configs:
jpa:
open-in-view: false
properties:
hibernate.jdbc.time_zone: UTC
hibernate.id.new_generator_mappings: true
hibernate.connection.provider_disables_autocommit: true
hibernate.cache.use_second_level_cache: false
hibernate.cache.use_query_cache: true
hibernate.generate_statistics: false
# modify batch size as necessary
hibernate.jdbc.batch_size: 25
hibernate.order_inserts: true
hibernate.order_updates: true
hibernate.query.fail_on_pagination_over_collection_fetch: true
hibernate.query.in_clause_parameter_padding: true
hibernate.dialect: org.hibernate.dialect.MySQL5Dialect
spring.jpa.show-sql: true