infinispan

Delete entries in infinispan embedded cache by query


I'm trying to delete a bunch of entries with something similar to the following code snippet.

    var query = "delete from package.Entity where field = :value";
    var count = cache.query(query)
        .setParameter("value", value)
        //.maxResults(total) --> throws org.infinispan.commons.CacheException: ISPN014057: DELETE statements cannot use paging (firstResult/maxResults)
        .executeStatement();

However, at most 100 entries are deleted. I'm aware that query.default-max-results defaults to 100, so I tried to set the query's maxResults to the number of entries that should be deleted, as the code keeps track of that number. But maxResults is not allowed for delete statements, resulting in a CacheException. Nevertheless, changing the cache's query.default-max-results to 200 resulted in 200 entries deleted.

How can I execute this statement and guarantee that all entries satisfying the query are deleted without changing query.default-max-results?


Solution

  • It is probably a bug, I opened https://issues.redhat.com/browse/ISPN-16808.