【问题标题】:Hazelcast Cache local and distributed cache configurationHazelcast Cache 本地和分布式缓存配置
【发布时间】:2020-08-14 04:17:55
【问题描述】:

我已将 Hazelcast 缓存配置为在 Spring Boot 应用程序中分发。

<group>
    <name>instance1</name>
    <password>pass</password>
</group>

<map name="users">
    <!-- <time-to-live-seconds>30</time-to-live-seconds> -->
    <max-idle-seconds>30</max-idle-seconds>
    <eviction-policy>LRU</eviction-policy>
    <max-size policy="PER_NODE">5000</max-size>
    <backup-count>0</backup-count>
    <async-backup-count>0</async-backup-count>
    <read-backup-data>false</read-backup-data>
</map>

<network>
    <port auto-increment="true" port-count="100">5701</port>
    <join>
        <multicast enabled="false">
            <multicast-group>224.2.2.3</multicast-group>
            <multicast-port>54327</multicast-port>
        </multicast>
        <!-- <tcp-ip enabled="false"> <member>127.0.0.1:5709</member> <member>127.0.0.1:5710</member> 
            </tcp-ip> -->
        <tcp-ip enabled="true">
            <interface>127.0.0.1</interface>
        </tcp-ip>
        <aws enabled="false" />
    </join>
</network>

<properties>
    <property name="hazelcast.http.healthcheck.enabled">false</property>
    <property name="hazelcast.health.monitoring.delay.seconds">3000</property>
    <property name="hazelcast.heartbeat.interval.seconds">1500</property>
    <property name="hazelcast.health.monitoring.level">SILENT</property>
    <property name="hazelcast.client.statistics.enabled">false</property>
    <property name="hazelcast.initial.min.cluster.size">0</property>
    <property name="hazelcast.initial.wait.seconds">0</property>
</properties>

如果我像上面那样创建一个组,并且无论我在哪里添加这个组,该实例缓存都是同步的。

我希望同一实例的本地缓存不应共享少量缓存。

如何在应用中同时做本地和分布式缓存?

【问题讨论】:

    标签: spring-boot caching hazelcast hazelcast-imap


    【解决方案1】:

    @Shakthi,Hazelcast 是一个分布式内存数据网格。所以你创建的每个对象都是分布式的。

    您可以做的是在每个服务中创建第二个隔离的 Hazelcast 实例,这样它就可以像本地缓存一样工作。

    【讨论】:

    • Hazelcast 允许分布式以及非分布式。如果我们不创建组,它将允许本地缓存。
    • @shakthi,如果你在每个成员上创建一个独立的 Hazelcast 节点,你就可以实现你想要的。还编辑了答案
    【解决方案2】:

    @Shakthi - 您正在寻找的是 NearCache。看看文档:http://docs.hazelcast.org/docs/3.10.2/manual/html-single/index.html#near-cache

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-11
      • 1970-01-01
      相关资源
      最近更新 更多