11.4. 使用 Data Grid Command Line Interface (CLI)创建缓存

使用 Data Grid CLI 以 XML 或 JSON 格式从模板或配置文件添加缓存。

前提条件

创建用户,并至少启动一个 Data Grid 服务器实例。

流程

  1. 创建与 Data Grid 的 CLI 连接。
  2. 使用 create cache 命令添加缓存定义。

    • 使用 --file 选项,从 XML 或 JSON 文件添加缓存定义。

      [//containers/default]> create cache --file=configuration.xml mycache
    • 使用 --template 选项从模板创建缓存定义。

      [//containers/default]> create cache --template=org.infinispan.DIST_SYNC mycache
      提示

      --template= 参数后按 tab 键以列出可用的缓存模板。

  3. 使用 ls 命令验证缓存是否存在。

    [//containers/default]> ls caches
    mycache
  4. 使用 describe 命令检索缓存配置。

    [//containers/default]> describe caches/mycache