Skip to content

Instantly share code, notes, and snippets.

@tristantarrant
Last active October 11, 2019 19:03
Show Gist options
  • Select an option

  • Save tristantarrant/3852366140e43ce5b5e1fdd8b548b44d to your computer and use it in GitHub Desktop.

Select an option

Save tristantarrant/3852366140e43ce5b5e1fdd8b548b44d to your computer and use it in GitHub Desktop.
Infinispan CLI Cheat Sheet

Create a cache using a template

create cache --template=org.infinispan.DIST_SYNC dcache

Create a permanent cache using a template

create cache --permanent=true --template=org.infinispan.DIST_SYNC dcache

Select a cache

cache dcache

Put an entry in the current cache

put k1 v1

Get an entry from the cache

get k1

Clear a cache

clearcache

Delete a cache

drop cache dcache

Create a queryable cache

create cache --file=qcache.xml qcache
<infinispan>
   <cache-container>
      <distributed-cache name="qcache">
         <encoding>
            <key media-type="application/x-protostream"/>
            <value media-type="application/x-protostream"/>
         </encoding>
      </distributed-cache>
   </cache-container>
</infinispan>

Upload a schema

cache ___protobuf_metadata
put --file=person.proto person.proto
package org.infinispan.rest.search.entity;
message Address {
    required string street = 1;
    required string postCode = 2;
}
message PhoneNumber {
    required string number = 1;
}
message Person {
    optional int32 id = 1;
    required string name = 2;
    required string surname = 3;
    optional Address address = 4;
    repeated PhoneNumber phoneNumbers = 5;
    optional uint32 age = 6;
    enum Gender {
        MALE = 0;
        FEMALE = 1;
    }
    optional Gender gender = 7;
}

Putting queryable entries in the cache

put --cache=qcache --file=lukecage.json lukecage
jessicajones.json
{
  "_type":"org.infinispan.rest.search.entity.Person",
  "id":1,
  "name":"Jessica",
  "surname":"Jones",
  "gender":"FEMALE",
  "address":{"street":"46th St","postCode":"NY 10036"},
  "phoneNumbers":[{"number":1111},{"number":2222},{"number":3333}]
}
matthewmurdock.json
{
  "_type":"org.infinispan.rest.search.entity.Person",
  "id":3,
  "name":"Matthew",
  "surname":"Murdock",
  "gender":"MALE",
  "address":{"street":"57th St","postCode":"NY 10019"},
  "phoneNumbers":[]
}
lukecage.json
{
  "_type":"org.infinispan.rest.search.entity.Person",
  "id":2,
  "name":"Luke",
  "surname":"Cage",
  "gender":"MALE",
  "address":{"street":"Malcolm X Boulevard","postCode":"NY 11221"},
  "phoneNumbers":[{"number":4444},{"number":5555}]
}

Querying a cache

query --cache=qcache "from org.infinispan.rest.search.entity.Person p where p.gender = 'MALE'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment