Is there a way to grab and remove entries from the cache using a query as opposed to referencing the key directly with cache.getAndRemove()? I need to be able to query for a single entry using a field other than the key and have the entry removed (i.e. not returned when other threads perform the same query). The use case is that I have multiple entries with the same field value. I need to be able to query for a single entry that matches the query and remove it so that no other threads (or nodes) executing that query return the same entry (i.e. they'll get a different entry that matches the query). I may be able to do what I need with an EntryProcessor that changes the value of the queried field provided that 1) no other thread blocks waiting for that entry and 2) the EntryProcessor returns the object that it modified. I'm not sure if that's possible, but any guidance would be appreciated.
Currently there is no direct way to do this, because SQL queries support only SELECT statements. But you can use it to find the entry (or entries) you want to remove, and then use IgniteCache.remove(K key) to actually delete the value(s). If you don't want to remove in case it was updated in the middle of the process, you can use the version of the method that also takes the old value to compare with: remove(K key, V oldVal). Here, if you provide the value that was returned by the query, the remove will be successful only if the value was not changed.