public static void removeAllWithStringPrefix(AbstractCache<String, ?> cache, String urlPrefix) { Set<String> keys = cache.keySet(); for (String key : keys) { if (key.startsWith(urlPrefix)) { cache.remove(key); } } if (cache.isDiskCacheEnabled()) { removeExpiredCache(cache, urlPrefix); } }