Py学习  »  DATABASE

spring boot rest服务存在太多mysql db调用问题

Tuhin Subhra Mandal • 3 年前 • 263 次点击  

我正在用one boot开发应用程序和rest。目前我仍处于开发阶段,因此我还没有启用任何缓存。未来随着负载的增加,我将使用memcached(我们已经在组织中的其他应用程序中使用memcached)或redis来缓存数据库查询的结果。 现在我甚至还没有启用hibernate二级缓存,所以我看到太多的db调用。 我想启用缓存来减少数据库调用。

我的是一个rest api,目前我们正在aws的3个POD中运行它。

我应该启用哪种缓存(不是memcached或redis)

  1. Spring缓存(ehcache)
  2. 休眠二级缓存

我现在的主要目标是减少数据库调用的数量。

我应该只使用hibernate二级缓存还是spring缓存?

以下是我的默认配置:

  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
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/128697
 
263 次点击  
文章 [ 1 ]  |  最新文章 3 年前