Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.

Chapter 2. Performing Cache Operations with the Data Grid CLI


The command line interface (CLI) lets you remotely connect to Data Grid servers to access data and perform administrative functions.

2.1. Creating Caches with the Data Grid Command Line Interface (CLI)

Use the Data Grid CLI to add caches from templates or configuration files in XML or JSON format.

Prerequisites

Create a user and start at least one Data Grid server instance.

Procedure

  1. Create a CLI connection to Data Grid.
  2. Add cache definitions with the create cache command.

    • Add a cache definition from an XML or JSON file with the --file option.

      [//containers/default]> create cache --file=configuration.xml mycache
      Copy to Clipboard Toggle word wrap
    • Add a cache definition from a template with the --template option.

      [//containers/default]> create cache --template=org.infinispan.DIST_SYNC mycache
      Copy to Clipboard Toggle word wrap
      Tip

      Press the tab key after the --template= argument to list available cache templates.

  3. Verify the cache exists with the ls command.

    [//containers/default]> ls caches
    mycache
    Copy to Clipboard Toggle word wrap
  4. Retrieve the cache configuration with the describe command.

    [//containers/default]> describe caches/mycache
    Copy to Clipboard Toggle word wrap

2.1.1. XML Configuration

Data Grid configuration in XML format must conform to the schema and include:

  • <infinispan> root element.
  • <cache-container> definition.

Example XML Configuration

<infinispan>
    <cache-container>
        <distributed-cache name="myCache" mode="SYNC">
          <encoding media-type="application/x-protostream"/>
          <memory max-count="1000000" when-full="REMOVE"/>
        </distributed-cache>
    </cache-container>
</infinispan>
Copy to Clipboard Toggle word wrap

2.1.2. JSON Configuration

Data Grid configuration in JSON format:

  • Requires the cache definition only.
  • Must follow the structure of an XML configuration.

    • XML elements become JSON objects.
    • XML attributes become JSON fields.

Example JSON Configuration

{
  "distributed-cache": {
    "name": "myCache",
    "mode": "SYNC",
    "encoding": {
      "media-type": "application/x-protostream"
      },
    "memory": {
      "max-count": 1000000,
      "when-full": "REMOVE"
    }
  }
}
Copy to Clipboard Toggle word wrap

2.2. Adding Cache Entries

Create key:value pair entries in the data container.

Prerequisites

Create a Data Grid cache that can store your data.

Procedure

  1. Create a CLI connection to Data Grid.
  2. Add entries into your cache as follows:

    • Use the put command from the context of a cache:

      [//containers/default/caches/mycache]> put hello world
      Copy to Clipboard Toggle word wrap
    • Use the --cache= with the put command:

      [//containers/default]> put --cache=mycache hello world
      Copy to Clipboard Toggle word wrap
  3. Use the get command to verify entries.

    [//containers/default/caches/mycache]> get hello
    world
    Copy to Clipboard Toggle word wrap

2.3. Clearing Caches and Deleting Entries

Remove data from caches with the Data Grid CLI.

Procedure

  1. Create a CLI connection to Data Grid.
  2. Do one of the following:

    • Delete all entries with the clearcache command.

      [//containers/default]> clearcache mycache
      Copy to Clipboard Toggle word wrap
    • Remove specific entries with the remove command.

      [//containers/default]> remove --cache=mycache hello
      Copy to Clipboard Toggle word wrap

2.4. Deleting Caches

Drop caches to remove them and delete all data they contain.

Procedure

  1. Create a CLI connection to Data Grid.
  2. Remove caches with the drop command.

    [//containers/default]> drop cache mycache
    Copy to Clipboard Toggle word wrap
Nach oben
Red Hat logoGithubredditYoutubeTwitter

Lernen

Testen, kaufen und verkaufen

Communitys

Über Red Hat Dokumentation

Wir helfen Red Hat Benutzern, mit unseren Produkten und Diensten innovativ zu sein und ihre Ziele zu erreichen – mit Inhalten, denen sie vertrauen können. Entdecken Sie unsere neuesten Updates.

Mehr Inklusion in Open Source

Red Hat hat sich verpflichtet, problematische Sprache in unserem Code, unserer Dokumentation und unseren Web-Eigenschaften zu ersetzen. Weitere Einzelheiten finden Sie in Red Hat Blog.

Über Red Hat

Wir liefern gehärtete Lösungen, die es Unternehmen leichter machen, plattform- und umgebungsübergreifend zu arbeiten, vom zentralen Rechenzentrum bis zum Netzwerkrand.

Theme

© 2025 Red Hat