【问题标题】:Spring Boot Application and Hazelcast NearCacheSpring Boot 应用程序和 Hazelcast NearCache
【发布时间】:2021-01-06 05:56:00
【问题描述】:

我正在尝试将 Hazelcast 缓存与 Spring Boot 一起使用,在阅读了一些文档后,我决定采用 Near Cache 配置,我想缓存一些方法调用并将其用于 Hibernate L2 缓存。问题是我没有完全没有看到使用 Near Cache 专门创建近缓存客户端并启动服务器的示例。 我可以提供一些代码示例来配置该设置(近缓存配置)以及如何启动服务器端。

【问题讨论】:

    标签: spring-boot caching hazelcast spring-cache hibernate-cache


    【解决方案1】:

    配置 Hibernate 以使用 Hazelcast 客户端:

    <!-- hibernate.cfg.xml --> 
    
    <property name="hibernate.cache.hazelcast.use_native_client">true</property>
    <property name="hibernate.cache.hazelcast.configuration_file_path">hazelcast-client.xml</property>
    

    在客户端配置中,配置近缓存:

    <!-- hazelcast-client.xml -->
    
    <near-cache name="default">
        <time-to-live-seconds>90</time-to-live-seconds>
        <max-idle-seconds>100</max-idle-seconds>
        <in-memory-format>OBJECT</in-memory-format>
    </near-cache>
    

    或者,您可以通过以下方式为每个缓存区域设置不同的配置:

    <near-cache name="<entity-cache-region-name>">
    

    这些将为 Hibernate L2C 启用客户端的近缓存。此时您不需要在服务器端添加任何其他配置。但是,如果您还想为成员配置近缓存,则可以独立于 Hibernate 和客户端进行配置。

    客户端和成员的配置详细信息在the documentation 中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-25
      • 1970-01-01
      • 2021-09-24
      • 1970-01-01
      • 2018-03-21
      • 1970-01-01
      • 2016-11-08
      • 2018-09-27
      相关资源
      最近更新 更多