首页 > 解决方案 > 如何使用兵马俑服务器实现集群缓存?

问题描述

有人可以告诉我如何使用 terracota 服务器在两个微服务之间实现集群缓存共享,任何参考项目都可以很好地开始

eh-cache.xml

ehcache xml : <?xml version="1.0" encoding="UTF-8"?>

<ehcache:config`enter code here`
  xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
  xmlns:terracotta='http://www.ehcache.org/v3/clustered'
  xmlns:ehcache='http://www.ehcache.org/v3'
  xsi:schemaLocation="http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core-3.8.xsd
    http://www.ehcache.org/v3/clustered http://www.ehcache.org/schema/ehcache-clustered-ext-3.8.xsd">

  <ehcache:service>
    <terracotta:cluster>
      <terracotta:connection url="terracotta://localhost:9410/clustered"/>
      <terracotta:server-side-config auto-create="true">
          <!--<terracotta:default-resource from="default-resource"/>-->
          <terracotta:shared-pool name="shared-pool-expense" unit="MB">100</terracotta:shared-pool>
      </terracotta:server-side-config>
    </terracotta:cluster>
 </ehcache:service>


  <ehcache:cache alias="areaOfCircleCache">
    <ehcache:key-type>java.lang.String</ehcache:key-type>
    <ehcache:value-type>com.db.entity.LogMessage</ehcache:value-type>
    <ehcache:resources>
      <!--      <ehcache:heap unit="entries">100</ehcache:heap>
       <ehcache:offheap unit="MB">10</ehcache:offheap>-->
      <terracotta:clustered-dedicated unit="MB">10</terracotta:clustered-dedicated>
    </ehcache:resources>
  </ehcache:cache>
</ehcache:config>

标签: cachingehcacheterracottaehcache-3

解决方案


这个问题相当大。我建议从文档开始,然后在您无法弄清楚的情况下提出具体问题。


推荐阅读