Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INTERNAL: Remove redundant method in FrontCacheMemcachedClient. #652

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 0 additions & 189 deletions src/main/java/net/spy/memcached/plugin/FrontCacheMemcachedClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,19 @@
import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.Map;
import java.util.Iterator;
import java.util.Arrays;
import java.util.HashMap;

import net.spy.memcached.ConnectionFactory;
import net.spy.memcached.MemcachedClient;
import net.spy.memcached.OperationTimeoutException;
import net.spy.memcached.internal.GetFuture;
import net.spy.memcached.internal.OperationFuture;
import net.spy.memcached.ops.OperationStatus;
import net.spy.memcached.ops.StatusCode;
import net.spy.memcached.internal.BulkFuture;
import net.spy.memcached.internal.BulkGetFuture;
import net.spy.memcached.internal.SingleElementInfiniteIterator;
import net.spy.memcached.transcoders.Transcoder;

/**
Expand Down Expand Up @@ -82,62 +76,6 @@ public FrontCacheMemcachedClient(ConnectionFactory cf,
}
}

/**
* Get with a single key and decode using the default transcoder.
*
* @param key the key to get
* @return the result from the cache (null if there is none)
* @throws OperationTimeoutException if the global operation timeout is
* exceeded
* @throws IllegalStateException in the rare circumstance where queue
* is too full to accept any more requests
*/
public Object get(String key) {
return get(key, transcoder);
}

/**
* Get with a single key.
*
* @param <T> Type of object to get.
* @param key the key to get
* @param tc the transcoder to serialize and unserialize value
* @return the result from the cache (null if there is none)
* @throws OperationTimeoutException if the global operation timeout is
* exceeded
* @throws IllegalStateException in the rare circumstance where queue
* is too full to accept any more requests
*/

public <T> T get(String key, Transcoder<T> tc) {
Future<T> future = asyncGet(key, tc);
try {
return future.get(operationTimeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
future.cancel(true);
throw new RuntimeException("Interrupted waiting for value", e);
} catch (ExecutionException e) {
future.cancel(true);
throw new RuntimeException("Exception waiting for value", e);
} catch (TimeoutException e) {
future.cancel(true);
throw new OperationTimeoutException(e);
}
}

/**
* Get the given key asynchronously and decode with the default
* transcoder.
*
* @param key the key to fetch
* @return a future that will hold the return value of the fetch
* @throws IllegalStateException in the rare circumstance where queue
* is too full to accept any more requests
*/
public GetFuture<Object> asyncGet(final String key) {
return asyncGet(key, transcoder);
}

/**
* Get the value of the key.
* Check the local cache first. If the key is not found, send the command to the server.
Expand Down Expand Up @@ -185,133 +123,6 @@ public OperationStatus getStatus() {
return new FrontCacheGetFuture<T>(localCacheManager, key, parent);
}

/**
* Get the values for multiple keys from the cache.
*
* @param keys the keys
* @return a map of the values (for each value that exists)
* @throws OperationTimeoutException if the global operation timeout is
* exceeded
* @throws IllegalStateException in the rare circumstance where queue
* is too full to accept any more requests
*/
public Map<String, Object> getBulk(Collection<String> keys) {
return getBulk(keys, transcoder);
}

/**
* Get the values for multiple keys from the cache.
*
* @param <T>
* @param tc the transcoder to serialize and unserialize value
* @param keys the keys
* @return a map of the values (for each value that exists)
* @throws OperationTimeoutException if the global operation timeout is
* exceeded
* @throws IllegalStateException in the rare circumstance where queue
* is too full to accept any more requests
*/
public <T> Map<String, T> getBulk(Transcoder<T> tc, String... keys) {
return getBulk(Arrays.asList(keys), tc);
}

/**
* Get the values for multiple keys from the cache.
*
* @param keys the keys
* @return a map of the values (for each value that exists)
* @throws OperationTimeoutException if the global operation timeout is
* exceeded
* @throws IllegalStateException in the rare circumstance where queue
* is too full to accept any more requests
*/
public Map<String, Object> getBulk(String... keys) {
return getBulk(Arrays.asList(keys), transcoder);
}

/**
* Get the values for multiple keys from the cache.
*
* @param <T>
* @param keys the keys
* @param tc the transcoder to serialize and unserialize value
* @return a map of the values (for each value that exists)
* @throws OperationTimeoutException if the global operation timeout is
* exceeded
* @throws IllegalStateException in the rare circumstance where queue
* is too full to accept any more requests
*/
public <T> Map<String, T> getBulk(Collection<String> keys,
Transcoder<T> tc) {
BulkFuture<Map<String, T>> future = asyncGetBulk(keys, tc);
try {
return future.get(operationTimeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
future.cancel(true);
throw new RuntimeException("Interrupted getting bulk values", e);
} catch (ExecutionException e) {
future.cancel(true);
throw new RuntimeException("Failed getting bulk values", e);
} catch (TimeoutException e) {
future.cancel(true);
throw new OperationTimeoutException(e);
}
}

/**
* Asynchronously get a bunch of objects from the cache.
*
* @param <T>
* @param keys the keys to request
* @param tc the transcoder to serialize and unserialize values
* @return a Future result of that fetch
* @throws IllegalStateException in the rare circumstance where queue
* is too full to accept any more requests
*/
public <T> BulkFuture<Map<String, T>> asyncGetBulk(Collection<String> keys, Transcoder<T> tc) {
return asyncGetBulk(keys, new SingleElementInfiniteIterator<Transcoder<T>>(tc));
}

/**
* Asynchronously get a bunch of objects from the cache and decode them
* with the given transcoder.
*
* @param keys the keys to request
* @return a Future result of that fetch
* @throws IllegalStateException in the rare circumstance where queue
* is too full to accept any more requests
*/
public BulkFuture<Map<String, Object>> asyncGetBulk(Collection<String> keys) {
return asyncGetBulk(keys, transcoder);
}

/**
* Varargs wrapper for asynchronous bulk get.
*
* @param <T>
* @param tc the transcoder to serialize and unserialize value
* @param keys one more keys to get
* @return the future values of those keys
* @throws IllegalStateException in the rare circumstance where queue
* is too full to accept any more requests
*/
public <T> BulkFuture<Map<String, T>> asyncGetBulk(Transcoder<T> tc,
String... keys) {
return asyncGetBulk(Arrays.asList(keys), tc);
}

/**
* Varargs wrapper for asynchronous bulk get with the default transcoder.
*
* @param keys one more keys to get
* @return the future values of those keys
* @throws IllegalStateException in the rare circumstance where queue
* is too full to accept any more requests
*/
public BulkFuture<Map<String, Object>> asyncGetBulk(String... keys) {
return asyncGetBulk(Arrays.asList(keys), transcoder);
}

/**
* Asynchronously gets (with CAS support) a bunch of objects from the cache.
* If used with front cache, the front cache is checked first.
Expand Down
Loading