Search code examples
javaoracle-coherence

Coherence Delete Entry with regular expression


I want to delete records in namedCache in which "key" value ends with special string like

key1AA-BB
key2AA-BB
key3AA-BB

is there simple way to delete all records whose key value ends with "AA-BB"?

in my expreriment I have found that there is Filters (LikeFilter ..etc) but these filters are appied into "value" rather than "key". Whay similar Filter logic cannot be appied based on key?

I can iterate all keys and find macthed keys, but there should be more OO way

      Set set = cache.keySet();
      Iterator iterator = set.iterator();
      while (iterator.hasNext()) {
         System.out.println(iterator.next());
//match key  cache.remove(key)
      }

Using: Coherence 12


Solution

  • you can use KeyExtractor,

    LikeFilter filter = new LikeFilter(new KeyExtractor(),"BB", '\0' , false );
    

    http://docs.oracle.com/middleware/1212/coherence/COHJR/index.html