Skip to content

Commit

Permalink
REFACTOR: Remove unused arg and constructor in localCacheManager.
Browse files Browse the repository at this point in the history
  • Loading branch information
brido4125 authored and jhpark816 committed Apr 16, 2024
1 parent 5450474 commit ba6e26c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public <T> GetFuture<T> asyncGet(final String key, final Transcoder<T> tc) {
return super.asyncGet(key, tc);
}

final T t = localCacheManager.get(key, tc);
final T t = localCacheManager.get(key);
if (t != null) {
return new GetFuture<T>(null, 0) {
@Override
Expand Down Expand Up @@ -159,7 +159,7 @@ public <T> BulkFuture<Map<String, T>> asyncGetBulk(Collection<String> keys,
while (keyIter.hasNext() && tc_iter.hasNext()) {
String key = keyIter.next();
Transcoder<T> tc = tc_iter.next();
T value = localCacheManager.get(key, tc);
T value = localCacheManager.get(key);
if (value != null) {
frontCacheHit.put(key, value);
continue;
Expand Down
11 changes: 3 additions & 8 deletions src/main/java/net/spy/memcached/plugin/LocalCacheManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import net.spy.memcached.compat.log.Logger;
import net.spy.memcached.compat.log.LoggerFactory;
import net.spy.memcached.transcoders.Transcoder;

import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
Expand All @@ -45,10 +44,6 @@ public class LocalCacheManager {
protected Cache cache;
protected String name;

public LocalCacheManager() {
this("DEFAULT_ARCUS_LOCAL_CACHE");
}

public LocalCacheManager(String name) {
this.name = name;
// create a undecorated Cache object.
Expand Down Expand Up @@ -77,7 +72,7 @@ public LocalCacheManager(String name, int max, int exptime, boolean copyOnRead,
}
}

public <T> T get(String key, Transcoder<T> tc) {
public <T> T get(String key) {
if (cache == null) {
return null;
}
Expand All @@ -97,10 +92,10 @@ public <T> T get(String key, Transcoder<T> tc) {
return null;
}

public <T> Future<T> asyncGet(final String key, final Transcoder<T> tc) {
public <T> Future<T> asyncGet(final String key) {
Task<T> task = new Task<T>(new Callable<T>() {
public T call() throws Exception {
return get(key, tc);
return get(key);
}
});
return task;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import net.spy.memcached.ConnectionFactoryBuilder;
import net.spy.memcached.internal.BulkFuture;
import net.spy.memcached.plugin.LocalCacheManager;
import net.spy.memcached.transcoders.Transcoder;

public class LocalCacheManagerTest extends TestCase {

Expand Down Expand Up @@ -63,8 +62,7 @@ public void testGet() throws Exception {
Future<Object> f = client.asyncGet(key);
Object result = f.get();

Transcoder<Object> tc = null;
Object cached = client.getLocalCacheManager().get(key, tc);
Object cached = client.getLocalCacheManager().get(key);

assertNotNull(result);
assertNotNull(cached);
Expand All @@ -76,7 +74,7 @@ public void testGet() throws Exception {
f = client.asyncGet(key);
result = f.get();

cached = client.getLocalCacheManager().get(key, tc);
cached = client.getLocalCacheManager().get(key);

assertNotNull(result);
assertNotNull(cached);
Expand All @@ -88,7 +86,7 @@ public void testGet() throws Exception {
f = client.asyncGet(key);
result = f.get();

cached = client.getLocalCacheManager().get(key, tc);
cached = client.getLocalCacheManager().get(key);

assertNull(result);
assertNull(cached);
Expand All @@ -105,8 +103,7 @@ public void testGetBulk() throws Exception {
// expecting that the keys are locally cached.
LocalCacheManager lcm = client.getLocalCacheManager();
for (String k : keys) {
Transcoder<Object> tc = null;
Object got = lcm.get(k, tc);
Object got = lcm.get(k);
assertNotNull(got);
}

Expand All @@ -123,8 +120,7 @@ public void testGetBulk() throws Exception {
Thread.sleep(3000);

for (String k : keys) {
Transcoder<Object> tc = null;
Object got = lcm.get(k, tc);
Object got = lcm.get(k);
assertNull(got);
}

Expand All @@ -145,8 +141,7 @@ public void testAsyncGetBulk() throws Exception {
// expecting that the keys are locally cached.
LocalCacheManager lcm = client.getLocalCacheManager();
for (String k : keys) {
Transcoder<Object> tc = null;
Object got = lcm.get(k, tc);
Object got = lcm.get(k);
assertNotNull(got);
}

Expand All @@ -164,8 +159,7 @@ public void testAsyncGetBulk() throws Exception {
Thread.sleep(3000);

for (String k : keys) {
Transcoder<Object> tc = null;
Object got = lcm.get(k, tc);
Object got = lcm.get(k);
assertNull(got);
}

Expand Down Expand Up @@ -196,8 +190,7 @@ public void testBulkPartial() throws Exception {
// expecting that the keys are locally cached.
LocalCacheManager lcm = client.getLocalCacheManager();
for (String k : keySet1) {
Transcoder<Object> tc = null;
Object got = lcm.get(k, tc);
Object got = lcm.get(k);
assertNotNull(got);
}

Expand All @@ -221,8 +214,7 @@ public void testBulkPartial() throws Exception {
Thread.sleep(3000);

for (String k : keySet1) {
Transcoder<Object> tc = null;
Object got = lcm.get(k, tc);
Object got = lcm.get(k);
assertNull(got);
}

Expand Down

0 comments on commit ba6e26c

Please sign in to comment.