mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
added removeAll method to cache
This commit is contained in:
@@ -40,6 +40,12 @@ import net.sf.ehcache.Element;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.Filter;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -126,6 +132,36 @@ public class EhCache<K, V> implements Cache<K, V>
|
||||
return cache.remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param filter
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean removeAll(Filter<K> filter)
|
||||
{
|
||||
boolean result = true;
|
||||
Iterator<K> it = cache.getKeys().iterator();
|
||||
|
||||
while (it.hasNext())
|
||||
{
|
||||
K key = it.next();
|
||||
|
||||
if (filter.accept(key))
|
||||
{
|
||||
if (!cache.remove(key))
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user