3.2.3. 缓存模板通配符

您可以添加通配符来缓存配置模板名称。如果您创建名称与通配符匹配的缓存,Data Grid 会应用配置模板。

注意

如果缓存名称匹配多个通配符,则数据网格会抛出异常。

模板通配符示例

XML

<infinispan>
   <cache-container>
      <distributed-cache-configuration name="async-dist-cache-*"
                                       mode="ASYNC"
                                       statistics="true">
        <encoding media-type="application/x-protostream"/>
      </distributed-cache-configuration>
   </cache-container>
</infinispan>

JSON

{
  "infinispan" : {
    "cache-container" : {
      "distributed-cache-configuration" : {
        "name" : "async-dist-cache-*",
        "mode": "ASYNC",
        "statistics": "true",
        "encoding": {
          "media-type": "application/x-protostream"
        }
      }
    }
  }
}

YAML

infinispan:
  cacheContainer:
    distributedCacheConfiguration:
      name: "async-dist-cache-*"
      mode: "ASYNC"
      statistics: "true"
      encoding:
        mediaType: "application/x-protostream"

使用上述示例,如果您创建一个名为 "async-dist-cache-prod" 的缓存,则 Data Grid 会使用 async-dist-cache-* 模板的配置。