本文整理了Java中net.spy.memcached.MemcachedClient.addOp()
方法的一些代码示例,展示了MemcachedClient.addOp()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MemcachedClient.addOp()
方法的具体详情如下:
包路径:net.spy.memcached.MemcachedClient
类名称:MemcachedClient
方法名:addOp
[英](internal use) Add a raw operation to a numbered connection. This method is exposed for testing.
[中](内部使用)向编号的连接添加原始操作。这种方法用于测试。
代码示例来源:origin: naver/arcus-java-client
private long mutate(Mutator m, String key, int by, long def, int exp) {
final AtomicLong rv = new AtomicLong();
final CountDownLatch latch = new CountDownLatch(1);
addOp(key, opFact.mutate(m, key, by, def, exp, new OperationCallback() {
public void receivedStatus(OperationStatus s) {
// XXX: Potential abstraction leak.
// The handling of incr/decr in the binary protocol
// Allows us to avoid string processing.
rv.set(new Long(s.isSuccess() ? s.getMessage() : "-1"));
}
public void complete() {
latch.countDown();
}
}));
try {
if (!latch.await(operationTimeout, TimeUnit.MILLISECONDS)) {
throw new OperationTimeoutException(
"Mutate operation timed out, unable to modify counter ["
+ key + "]");
}
} catch (InterruptedException e) {
throw new RuntimeException("Interrupted", e);
}
getLogger().debug("Mutation returned %s", rv);
return rv.get();
}
代码示例来源:origin: com.google.code.maven-play-plugin.spy/spymemcached
private Future<Long> asyncMutate(Mutator m, String key, int by, long def,
int exp) {
final CountDownLatch latch = new CountDownLatch(1);
final OperationFuture<Long> rv = new OperationFuture<Long>(
latch, operationTimeout);
Operation op = addOp(key, opFact.mutate(m, key, by, def, exp,
new OperationCallback() {
public void receivedStatus(OperationStatus s) {
rv.set(new Long(s.isSuccess() ? s.getMessage() : "-1"));
}
public void complete() {
latch.countDown();
}
}));
rv.setOperation(op);
return rv;
}
代码示例来源:origin: com.google.code.maven-play-plugin.spy/memcached
private Future<Long> asyncMutate(Mutator m, String key, int by, long def,
int exp) {
final CountDownLatch latch = new CountDownLatch(1);
final OperationFuture<Long> rv = new OperationFuture<Long>(
latch, operationTimeout);
Operation op = addOp(key, opFact.mutate(m, key, by, def, exp,
new OperationCallback() {
public void receivedStatus(OperationStatus s) {
rv.set(new Long(s.isSuccess() ? s.getMessage() : "-1"));
}
public void complete() {
latch.countDown();
}
}));
rv.setOperation(op);
return rv;
}
代码示例来源:origin: com.google.code.maven-play-plugin.spy/memcached
private long mutate(Mutator m, String key, int by, long def, int exp) {
final AtomicLong rv=new AtomicLong();
final CountDownLatch latch=new CountDownLatch(1);
addOp(key, opFact.mutate(m, key, by, def, exp, new OperationCallback() {
public void receivedStatus(OperationStatus s) {
// XXX: Potential abstraction leak.
// The handling of incr/decr in the binary protocol
// Allows us to avoid string processing.
rv.set(new Long(s.isSuccess()?s.getMessage():"-1"));
}
public void complete() {
latch.countDown();
}}));
try {
if (!latch.await(operationTimeout, TimeUnit.MILLISECONDS)) {
throw new OperationTimeoutException(
"Mutate operation timed out, unable to modify counter ["
+ key + "]");
}
} catch (InterruptedException e) {
throw new RuntimeException("Interrupted", e);
}
getLogger().debug("Mutation returned %s", rv);
return rv.get();
}
代码示例来源:origin: com.google.code.maven-play-plugin.spy/spymemcached
private long mutate(Mutator m, String key, int by, long def, int exp) {
final AtomicLong rv=new AtomicLong();
final CountDownLatch latch=new CountDownLatch(1);
addOp(key, opFact.mutate(m, key, by, def, exp, new OperationCallback() {
public void receivedStatus(OperationStatus s) {
// XXX: Potential abstraction leak.
// The handling of incr/decr in the binary protocol
// Allows us to avoid string processing.
rv.set(new Long(s.isSuccess()?s.getMessage():"-1"));
}
public void complete() {
latch.countDown();
}}));
try {
if (!latch.await(operationTimeout, TimeUnit.MILLISECONDS)) {
throw new OperationTimeoutException(
"Mutate operation timed out, unable to modify counter ["
+ key + "]");
}
} catch (InterruptedException e) {
throw new RuntimeException("Interrupted", e);
}
getLogger().debug("Mutation returned %s", rv);
return rv.get();
}
代码示例来源:origin: naver/arcus-java-client
private Future<Long> asyncMutate(Mutator m, String key, int by, long def,
int exp) {
final CountDownLatch latch = new CountDownLatch(1);
final OperationFuture<Long> rv = new OperationFuture<Long>(
latch, operationTimeout);
Operation op = addOp(key, opFact.mutate(m, key, by, def, exp,
new OperationCallback() {
public void receivedStatus(OperationStatus s) {
rv.set(new Long(s.isSuccess() ? s.getMessage() : "-1"));
}
public void complete() {
latch.countDown();
}
}));
rv.setOperation(op);
return rv;
}
代码示例来源:origin: com.google.code.maven-play-plugin.spy/spymemcached
/**
* Delete the given key from the cache.
*
* @param key the key to delete
* @return whether or not the operation was performed
* @throws IllegalStateException in the rare circumstance where queue
* is too full to accept any more requests
*/
public Future<Boolean> delete(String key) {
final CountDownLatch latch=new CountDownLatch(1);
final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
operationTimeout);
DeleteOperation op=opFact.delete(key,
new OperationCallback() {
public void receivedStatus(OperationStatus s) {
rv.set(s.isSuccess());
}
public void complete() {
latch.countDown();
}});
rv.setOperation(op);
addOp(key, op);
return rv;
}
代码示例来源:origin: com.google.code.maven-play-plugin.spy/memcached
/**
* Delete the given key from the cache.
*
* @param key the key to delete
* @throws IllegalStateException in the rare circumstance where queue
* is too full to accept any more requests
*/
public Future<Boolean> delete(String key) {
final CountDownLatch latch=new CountDownLatch(1);
final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
operationTimeout);
DeleteOperation op=opFact.delete(key,
new OperationCallback() {
public void receivedStatus(OperationStatus s) {
rv.set(s.isSuccess());
}
public void complete() {
latch.countDown();
}});
rv.setOperation(op);
addOp(key, op);
return rv;
}
代码示例来源:origin: com.google.code.maven-play-plugin.spy/memcached
/**
* Get the given key asynchronously.
*
* @param key the key to fetch
* @param tc the transcoder to serialize and unserialize value
* @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 <T> Future<T> asyncGet(final String key, final Transcoder<T> tc) {
final CountDownLatch latch=new CountDownLatch(1);
final GetFuture<T> rv=new GetFuture<T>(latch, operationTimeout);
Operation op=opFact.get(key,
new GetOperation.Callback() {
private Future<T> val=null;
public void receivedStatus(OperationStatus status) {
rv.set(val);
}
public void gotData(String k, int flags, byte[] data) {
assert key.equals(k) : "Wrong key returned";
val=tcService.decode(tc,
new CachedData(flags, data, tc.getMaxSize()));
}
public void complete() {
latch.countDown();
}});
rv.setOperation(op);
addOp(key, op);
return rv;
}
代码示例来源:origin: naver/arcus-java-client
/**
* Delete the given key from the cache.
*
* @param key the key to delete
* @return whether or not the operation was performed
* @throws IllegalStateException in the rare circumstance where queue
* is too full to accept any more requests
*/
public Future<Boolean> delete(String key) {
final CountDownLatch latch = new CountDownLatch(1);
final OperationFuture<Boolean> rv = new OperationFuture<Boolean>(latch,
operationTimeout);
DeleteOperation op = opFact.delete(key,
new OperationCallback() {
public void receivedStatus(OperationStatus s) {
rv.set(s.isSuccess());
}
public void complete() {
latch.countDown();
}
});
rv.setOperation(op);
addOp(key, op);
return rv;
}
代码示例来源:origin: com.google.code.maven-play-plugin.spy/memcached
}});
rv.setOperation(op);
addOp(key, op);
return rv;
代码示例来源:origin: naver/arcus-java-client
addOp(key, op);
return rv;
代码示例来源:origin: com.google.code.maven-play-plugin.spy/spymemcached
}});
rv.setOperation(op);
addOp(key, op);
return rv;
代码示例来源:origin: com.google.code.maven-play-plugin.spy/spymemcached
private <T> Future<Boolean> asyncCat(
ConcatenationType catType, long cas, String key,
T value, Transcoder<T> tc) {
CachedData co=tc.encode(value);
final CountDownLatch latch=new CountDownLatch(1);
final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
operationTimeout);
Operation op=opFact.cat(catType, cas, key, co.getData(),
new OperationCallback() {
public void receivedStatus(OperationStatus val) {
rv.set(val.isSuccess());
}
public void complete() {
latch.countDown();
}});
rv.setOperation(op);
addOp(key, op);
return rv;
}
代码示例来源:origin: com.google.code.maven-play-plugin.spy/memcached
private <T> Future<Boolean> asyncCat(
ConcatenationType catType, long cas, String key,
T value, Transcoder<T> tc) {
CachedData co=tc.encode(value);
final CountDownLatch latch=new CountDownLatch(1);
final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
operationTimeout);
Operation op=opFact.cat(catType, cas, key, co.getData(),
new OperationCallback() {
public void receivedStatus(OperationStatus val) {
rv.set(val.isSuccess());
}
public void complete() {
latch.countDown();
}});
rv.setOperation(op);
addOp(key, op);
return rv;
}
代码示例来源:origin: naver/arcus-java-client
private <T> Future<Boolean> asyncCat(
ConcatenationType catType, long cas, String key,
T value, Transcoder<T> tc) {
CachedData co = tc.encode(value);
final CountDownLatch latch = new CountDownLatch(1);
final OperationFuture<Boolean> rv = new OperationFuture<Boolean>(latch,
operationTimeout);
Operation op = opFact.cat(catType, cas, key, co.getData(),
new OperationCallback() {
public void receivedStatus(OperationStatus val) {
rv.set(val.isSuccess());
}
public void complete() {
latch.countDown();
}
});
rv.setOperation(op);
addOp(key, op);
return rv;
}
代码示例来源:origin: com.google.code.maven-play-plugin.spy/spymemcached
private <T> Future<Boolean> asyncStore(StoreType storeType, String key,
int exp, T value, Transcoder<T> tc) {
CachedData co=tc.encode(value);
final CountDownLatch latch=new CountDownLatch(1);
final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
operationTimeout);
Operation op=opFact.store(storeType, key, co.getFlags(),
exp, co.getData(), new OperationCallback() {
public void receivedStatus(OperationStatus val) {
rv.set(val.isSuccess());
}
public void complete() {
latch.countDown();
}});
rv.setOperation(op);
addOp(key, op);
return rv;
}
代码示例来源:origin: com.google.code.maven-play-plugin.spy/memcached
private <T> Future<Boolean> asyncStore(StoreType storeType, String key,
int exp, T value, Transcoder<T> tc) {
CachedData co=tc.encode(value);
final CountDownLatch latch=new CountDownLatch(1);
final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
operationTimeout);
Operation op=opFact.store(storeType, key, co.getFlags(),
exp, co.getData(), new OperationCallback() {
public void receivedStatus(OperationStatus val) {
rv.set(val.isSuccess());
}
public void complete() {
latch.countDown();
}});
rv.setOperation(op);
addOp(key, op);
return rv;
}
代码示例来源:origin: naver/arcus-java-client
private <T> Future<Boolean> asyncStore(StoreType storeType, String key,
int exp, T value, Transcoder<T> tc) {
CachedData co = tc.encode(value);
final CountDownLatch latch = new CountDownLatch(1);
final OperationFuture<Boolean> rv = new OperationFuture<Boolean>(latch,
operationTimeout);
Operation op = opFact.store(storeType, key, co.getFlags(),
exp, co.getData(), new OperationCallback() {
public void receivedStatus(OperationStatus val) {
rv.set(val.isSuccess());
}
public void complete() {
latch.countDown();
}
});
rv.setOperation(op);
addOp(key, op);
return rv;
}
代码示例来源:origin: com.google.code.maven-play-plugin.spy/spymemcached
}});
rv.setOperation(op);
addOp(key, op);
return rv;
内容来源于网络,如有侵权,请联系作者删除!