Skip to content

Commit

Permalink
Merge pull request #37 from boyusun-SAG/AddRemoveToEhcache
Browse files Browse the repository at this point in the history
Add remove operation to Ehcache
  • Loading branch information
anthonydahanne authored May 11, 2018
2 parents 6c5119d + 2b793ac commit 65d583c
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public CacheManagerBusinessReflectionImpl(KitAwareClassLoaderDelegator kitAwareC
private void pound(Object cache, Integer intensity) {
IntStream.range(0, intensity).forEach(value -> {
put(cache, ThreadLocalRandom.current().nextLong(0, intensity * 1000), longString(intensity));
remove(cache, ThreadLocalRandom.current().nextLong(0, intensity * 100));
IntStream.range(0, 3).forEach(getIterationValue -> get(cache, ThreadLocalRandom.current().nextLong(0, intensity * 1000)));
});
}
Expand Down Expand Up @@ -100,6 +101,16 @@ private void put(Object cache, long key, String value) {
}
}

private void remove(Object cache, long key) {
try {
Class<?> cacheClass = loadClass("org.ehcache.core.Ehcache");
Method removeCacheMethod = cacheClass.getMethod("remove", Object.class);
removeCacheMethod.invoke(cache, key);
} catch (Exception e) {
throw new RuntimeException(e);
}
}

private Object getCache(String cacheAlias) {
if (cacheManager == null) {
return null;
Expand Down

0 comments on commit 65d583c

Please sign in to comment.