0

I am calling Apache Ignite Cluster using REST Api :

http://restapi-ignite-grid/ignite?cmd=size&cacheName=MyCache

and I am getting back JSON :

{"successStatus":0,"affinityNodeId":null,"sessionToken":null,"error":null,"response":10}

From what I understand that means I have 10 objects in the cache "MyCache". However when I am trying to get specific object by key I am getting nothing :

http://restapi-ignite-grid/ignite?cmd=get&key=1&cacheName=MyCache

{"successStatus":0,"affinityNodeId":<someValue>,"sessionToken":null,"error":null,"response":null}

My application is not constructing name/value pairs that we put in cache, so the actual key could be different.

I have couple of questions :

  1. How do I get the list of all the keys in the particular cache? ( I can only use REST API calls )
  2. How can remove all objects from particular cache without restarting cluster?
vs777
  • 564
  • 2
  • 11
  • 24

1 Answers1

0

See here for REST documentation.

In short, get gets the value associated with the key you specified. So, unless there's an integer key with the value of 1, you're not going to get any records that way.

  1. You need the Scan Query or SQL Fields Query which return lists of records. There's no method that returns all the records. There are people using Ignite who store billions of records in a single cache
  2. There's no "remove all" command available from the REST API. Most of the other APIs have a clear method
Stephen Darlington
  • 51,577
  • 12
  • 107
  • 152
  • Thank you. What do you mean by "most of the APIs have a clear method"? I checked Ignite Rest API and didn't find "clear" command. I also checked "ignitevisorcmd" and there I can use "cache" command to get the entries as well as clear the cache. Unfortunately in our current setup ( Ignite Cluster runs in OpenShift container ) I don't have an access to the utility – vs777 Oct 12 '21 at 14:44
  • [Java thick client](https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/IgniteCache.html#clear--), [Java thin client](https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/client/ClientCache.html#clear--), [.net](https://ignite.apache.org/releases/latest/dotnetdoc/api/Apache.Ignite.Core.Cache.ICache-2.html#Apache_Ignite_Core_Cache_ICache_2_Clear), [C++ thick](https://ignite.apache.org/releases/latest/cppdoc/classignite_1_1cache_1_1Cache.html#a32dff73e2749850adff3b8604a2b11b4), etc. – Stephen Darlington Oct 12 '21 at 16:24