Skip to content

Commit

Permalink
ehcache 2 ops optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
aurbroszniowski committed Nov 26, 2015
1 parent 793a043 commit 1800667
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ public void exec(final StatisticsHolder statisticsHolder, final Map<Class<? exte
List<Ehcache> caches = cacheConfig.getCaches();
for (final Ehcache cache : caches) {
Element value;
Object k = keyGenerator.generate(next);

long start = getTimeInNs();
try {
value = cache.get(keyGenerator.generate(next));
value = cache.get(k);
long end = getTimeInNs();
if (value == null) {
statisticsHolder.record(cache.getName(), (end - start), MISS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ public void exec(final StatisticsHolder statisticsHolder, final Map<Class<? exte
final long next = this.sequenceGenerator.next();
List<Ehcache> caches = cacheConfig.getCaches();
for (final Ehcache cache : caches) {
Object k = keyGenerator.generate(next);
Object v = valueGenerator.generate(next);

long start = getTimeInNs();
try {
cache.put(new Element(keyGenerator.generate(next), valueGenerator.generate(next)));
cache.put(new Element(k, v));
long end = getTimeInNs();
statisticsHolder.record(cache.getName(), (end - start), PUT);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ public void exec(final StatisticsHolder statisticsHolder, final Map<Class<? exte
List<Ehcache> caches = cacheConfig.getCaches();
for (final Ehcache cache : caches) {
boolean removed;
Object k = keyGenerator.generate(next);

long start = getTimeInNs();
try {
removed = cache.remove(keyGenerator.generate(next));
removed = cache.remove(k);
long end = getTimeInNs();
if (removed) {
statisticsHolder.record(cache.getName(), (end - start), REMOVE);
Expand Down

0 comments on commit 1800667

Please sign in to comment.