net.spy.memcached.MemcachedClient.addOp()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(11.2k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中net.spy.memcached.MemcachedClient.addOp()方法的一些代码示例,展示了MemcachedClient.addOp()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MemcachedClient.addOp()方法的具体详情如下:
包路径:net.spy.memcached.MemcachedClient
类名称:MemcachedClient
方法名:addOp

MemcachedClient.addOp介绍

[英](internal use) Add a raw operation to a numbered connection. This method is exposed for testing.
[中](内部使用)向编号的连接添加原始操作。这种方法用于测试。

代码示例

代码示例来源:origin: naver/arcus-java-client

  1. private long mutate(Mutator m, String key, int by, long def, int exp) {
  2. final AtomicLong rv = new AtomicLong();
  3. final CountDownLatch latch = new CountDownLatch(1);
  4. addOp(key, opFact.mutate(m, key, by, def, exp, new OperationCallback() {
  5. public void receivedStatus(OperationStatus s) {
  6. // XXX: Potential abstraction leak.
  7. // The handling of incr/decr in the binary protocol
  8. // Allows us to avoid string processing.
  9. rv.set(new Long(s.isSuccess() ? s.getMessage() : "-1"));
  10. }
  11. public void complete() {
  12. latch.countDown();
  13. }
  14. }));
  15. try {
  16. if (!latch.await(operationTimeout, TimeUnit.MILLISECONDS)) {
  17. throw new OperationTimeoutException(
  18. "Mutate operation timed out, unable to modify counter ["
  19. + key + "]");
  20. }
  21. } catch (InterruptedException e) {
  22. throw new RuntimeException("Interrupted", e);
  23. }
  24. getLogger().debug("Mutation returned %s", rv);
  25. return rv.get();
  26. }

代码示例来源:origin: com.google.code.maven-play-plugin.spy/spymemcached

  1. private Future<Long> asyncMutate(Mutator m, String key, int by, long def,
  2. int exp) {
  3. final CountDownLatch latch = new CountDownLatch(1);
  4. final OperationFuture<Long> rv = new OperationFuture<Long>(
  5. latch, operationTimeout);
  6. Operation op = addOp(key, opFact.mutate(m, key, by, def, exp,
  7. new OperationCallback() {
  8. public void receivedStatus(OperationStatus s) {
  9. rv.set(new Long(s.isSuccess() ? s.getMessage() : "-1"));
  10. }
  11. public void complete() {
  12. latch.countDown();
  13. }
  14. }));
  15. rv.setOperation(op);
  16. return rv;
  17. }

代码示例来源:origin: com.google.code.maven-play-plugin.spy/memcached

  1. private Future<Long> asyncMutate(Mutator m, String key, int by, long def,
  2. int exp) {
  3. final CountDownLatch latch = new CountDownLatch(1);
  4. final OperationFuture<Long> rv = new OperationFuture<Long>(
  5. latch, operationTimeout);
  6. Operation op = addOp(key, opFact.mutate(m, key, by, def, exp,
  7. new OperationCallback() {
  8. public void receivedStatus(OperationStatus s) {
  9. rv.set(new Long(s.isSuccess() ? s.getMessage() : "-1"));
  10. }
  11. public void complete() {
  12. latch.countDown();
  13. }
  14. }));
  15. rv.setOperation(op);
  16. return rv;
  17. }

代码示例来源:origin: com.google.code.maven-play-plugin.spy/memcached

  1. private long mutate(Mutator m, String key, int by, long def, int exp) {
  2. final AtomicLong rv=new AtomicLong();
  3. final CountDownLatch latch=new CountDownLatch(1);
  4. addOp(key, opFact.mutate(m, key, by, def, exp, new OperationCallback() {
  5. public void receivedStatus(OperationStatus s) {
  6. // XXX: Potential abstraction leak.
  7. // The handling of incr/decr in the binary protocol
  8. // Allows us to avoid string processing.
  9. rv.set(new Long(s.isSuccess()?s.getMessage():"-1"));
  10. }
  11. public void complete() {
  12. latch.countDown();
  13. }}));
  14. try {
  15. if (!latch.await(operationTimeout, TimeUnit.MILLISECONDS)) {
  16. throw new OperationTimeoutException(
  17. "Mutate operation timed out, unable to modify counter ["
  18. + key + "]");
  19. }
  20. } catch (InterruptedException e) {
  21. throw new RuntimeException("Interrupted", e);
  22. }
  23. getLogger().debug("Mutation returned %s", rv);
  24. return rv.get();
  25. }

代码示例来源:origin: com.google.code.maven-play-plugin.spy/spymemcached

  1. private long mutate(Mutator m, String key, int by, long def, int exp) {
  2. final AtomicLong rv=new AtomicLong();
  3. final CountDownLatch latch=new CountDownLatch(1);
  4. addOp(key, opFact.mutate(m, key, by, def, exp, new OperationCallback() {
  5. public void receivedStatus(OperationStatus s) {
  6. // XXX: Potential abstraction leak.
  7. // The handling of incr/decr in the binary protocol
  8. // Allows us to avoid string processing.
  9. rv.set(new Long(s.isSuccess()?s.getMessage():"-1"));
  10. }
  11. public void complete() {
  12. latch.countDown();
  13. }}));
  14. try {
  15. if (!latch.await(operationTimeout, TimeUnit.MILLISECONDS)) {
  16. throw new OperationTimeoutException(
  17. "Mutate operation timed out, unable to modify counter ["
  18. + key + "]");
  19. }
  20. } catch (InterruptedException e) {
  21. throw new RuntimeException("Interrupted", e);
  22. }
  23. getLogger().debug("Mutation returned %s", rv);
  24. return rv.get();
  25. }

代码示例来源:origin: naver/arcus-java-client

  1. private Future<Long> asyncMutate(Mutator m, String key, int by, long def,
  2. int exp) {
  3. final CountDownLatch latch = new CountDownLatch(1);
  4. final OperationFuture<Long> rv = new OperationFuture<Long>(
  5. latch, operationTimeout);
  6. Operation op = addOp(key, opFact.mutate(m, key, by, def, exp,
  7. new OperationCallback() {
  8. public void receivedStatus(OperationStatus s) {
  9. rv.set(new Long(s.isSuccess() ? s.getMessage() : "-1"));
  10. }
  11. public void complete() {
  12. latch.countDown();
  13. }
  14. }));
  15. rv.setOperation(op);
  16. return rv;
  17. }

代码示例来源:origin: com.google.code.maven-play-plugin.spy/spymemcached

  1. /**
  2. * Delete the given key from the cache.
  3. *
  4. * @param key the key to delete
  5. * @return whether or not the operation was performed
  6. * @throws IllegalStateException in the rare circumstance where queue
  7. * is too full to accept any more requests
  8. */
  9. public Future<Boolean> delete(String key) {
  10. final CountDownLatch latch=new CountDownLatch(1);
  11. final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
  12. operationTimeout);
  13. DeleteOperation op=opFact.delete(key,
  14. new OperationCallback() {
  15. public void receivedStatus(OperationStatus s) {
  16. rv.set(s.isSuccess());
  17. }
  18. public void complete() {
  19. latch.countDown();
  20. }});
  21. rv.setOperation(op);
  22. addOp(key, op);
  23. return rv;
  24. }

代码示例来源:origin: com.google.code.maven-play-plugin.spy/memcached

  1. /**
  2. * Delete the given key from the cache.
  3. *
  4. * @param key the key to delete
  5. * @throws IllegalStateException in the rare circumstance where queue
  6. * is too full to accept any more requests
  7. */
  8. public Future<Boolean> delete(String key) {
  9. final CountDownLatch latch=new CountDownLatch(1);
  10. final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
  11. operationTimeout);
  12. DeleteOperation op=opFact.delete(key,
  13. new OperationCallback() {
  14. public void receivedStatus(OperationStatus s) {
  15. rv.set(s.isSuccess());
  16. }
  17. public void complete() {
  18. latch.countDown();
  19. }});
  20. rv.setOperation(op);
  21. addOp(key, op);
  22. return rv;
  23. }

代码示例来源:origin: com.google.code.maven-play-plugin.spy/memcached

  1. /**
  2. * Get the given key asynchronously.
  3. *
  4. * @param key the key to fetch
  5. * @param tc the transcoder to serialize and unserialize value
  6. * @return a future that will hold the return value of the fetch
  7. * @throws IllegalStateException in the rare circumstance where queue
  8. * is too full to accept any more requests
  9. */
  10. public <T> Future<T> asyncGet(final String key, final Transcoder<T> tc) {
  11. final CountDownLatch latch=new CountDownLatch(1);
  12. final GetFuture<T> rv=new GetFuture<T>(latch, operationTimeout);
  13. Operation op=opFact.get(key,
  14. new GetOperation.Callback() {
  15. private Future<T> val=null;
  16. public void receivedStatus(OperationStatus status) {
  17. rv.set(val);
  18. }
  19. public void gotData(String k, int flags, byte[] data) {
  20. assert key.equals(k) : "Wrong key returned";
  21. val=tcService.decode(tc,
  22. new CachedData(flags, data, tc.getMaxSize()));
  23. }
  24. public void complete() {
  25. latch.countDown();
  26. }});
  27. rv.setOperation(op);
  28. addOp(key, op);
  29. return rv;
  30. }

代码示例来源:origin: naver/arcus-java-client

  1. /**
  2. * Delete the given key from the cache.
  3. *
  4. * @param key the key to delete
  5. * @return whether or not the operation was performed
  6. * @throws IllegalStateException in the rare circumstance where queue
  7. * is too full to accept any more requests
  8. */
  9. public Future<Boolean> delete(String key) {
  10. final CountDownLatch latch = new CountDownLatch(1);
  11. final OperationFuture<Boolean> rv = new OperationFuture<Boolean>(latch,
  12. operationTimeout);
  13. DeleteOperation op = opFact.delete(key,
  14. new OperationCallback() {
  15. public void receivedStatus(OperationStatus s) {
  16. rv.set(s.isSuccess());
  17. }
  18. public void complete() {
  19. latch.countDown();
  20. }
  21. });
  22. rv.setOperation(op);
  23. addOp(key, op);
  24. return rv;
  25. }

代码示例来源:origin: com.google.code.maven-play-plugin.spy/memcached

  1. }});
  2. rv.setOperation(op);
  3. addOp(key, op);
  4. return rv;

代码示例来源:origin: naver/arcus-java-client

  1. addOp(key, op);
  2. return rv;

代码示例来源:origin: com.google.code.maven-play-plugin.spy/spymemcached

  1. }});
  2. rv.setOperation(op);
  3. addOp(key, op);
  4. return rv;

代码示例来源:origin: com.google.code.maven-play-plugin.spy/spymemcached

  1. private <T> Future<Boolean> asyncCat(
  2. ConcatenationType catType, long cas, String key,
  3. T value, Transcoder<T> tc) {
  4. CachedData co=tc.encode(value);
  5. final CountDownLatch latch=new CountDownLatch(1);
  6. final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
  7. operationTimeout);
  8. Operation op=opFact.cat(catType, cas, key, co.getData(),
  9. new OperationCallback() {
  10. public void receivedStatus(OperationStatus val) {
  11. rv.set(val.isSuccess());
  12. }
  13. public void complete() {
  14. latch.countDown();
  15. }});
  16. rv.setOperation(op);
  17. addOp(key, op);
  18. return rv;
  19. }

代码示例来源:origin: com.google.code.maven-play-plugin.spy/memcached

  1. private <T> Future<Boolean> asyncCat(
  2. ConcatenationType catType, long cas, String key,
  3. T value, Transcoder<T> tc) {
  4. CachedData co=tc.encode(value);
  5. final CountDownLatch latch=new CountDownLatch(1);
  6. final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
  7. operationTimeout);
  8. Operation op=opFact.cat(catType, cas, key, co.getData(),
  9. new OperationCallback() {
  10. public void receivedStatus(OperationStatus val) {
  11. rv.set(val.isSuccess());
  12. }
  13. public void complete() {
  14. latch.countDown();
  15. }});
  16. rv.setOperation(op);
  17. addOp(key, op);
  18. return rv;
  19. }

代码示例来源:origin: naver/arcus-java-client

  1. private <T> Future<Boolean> asyncCat(
  2. ConcatenationType catType, long cas, String key,
  3. T value, Transcoder<T> tc) {
  4. CachedData co = tc.encode(value);
  5. final CountDownLatch latch = new CountDownLatch(1);
  6. final OperationFuture<Boolean> rv = new OperationFuture<Boolean>(latch,
  7. operationTimeout);
  8. Operation op = opFact.cat(catType, cas, key, co.getData(),
  9. new OperationCallback() {
  10. public void receivedStatus(OperationStatus val) {
  11. rv.set(val.isSuccess());
  12. }
  13. public void complete() {
  14. latch.countDown();
  15. }
  16. });
  17. rv.setOperation(op);
  18. addOp(key, op);
  19. return rv;
  20. }

代码示例来源:origin: com.google.code.maven-play-plugin.spy/spymemcached

  1. private <T> Future<Boolean> asyncStore(StoreType storeType, String key,
  2. int exp, T value, Transcoder<T> tc) {
  3. CachedData co=tc.encode(value);
  4. final CountDownLatch latch=new CountDownLatch(1);
  5. final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
  6. operationTimeout);
  7. Operation op=opFact.store(storeType, key, co.getFlags(),
  8. exp, co.getData(), new OperationCallback() {
  9. public void receivedStatus(OperationStatus val) {
  10. rv.set(val.isSuccess());
  11. }
  12. public void complete() {
  13. latch.countDown();
  14. }});
  15. rv.setOperation(op);
  16. addOp(key, op);
  17. return rv;
  18. }

代码示例来源:origin: com.google.code.maven-play-plugin.spy/memcached

  1. private <T> Future<Boolean> asyncStore(StoreType storeType, String key,
  2. int exp, T value, Transcoder<T> tc) {
  3. CachedData co=tc.encode(value);
  4. final CountDownLatch latch=new CountDownLatch(1);
  5. final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
  6. operationTimeout);
  7. Operation op=opFact.store(storeType, key, co.getFlags(),
  8. exp, co.getData(), new OperationCallback() {
  9. public void receivedStatus(OperationStatus val) {
  10. rv.set(val.isSuccess());
  11. }
  12. public void complete() {
  13. latch.countDown();
  14. }});
  15. rv.setOperation(op);
  16. addOp(key, op);
  17. return rv;
  18. }

代码示例来源:origin: naver/arcus-java-client

  1. private <T> Future<Boolean> asyncStore(StoreType storeType, String key,
  2. int exp, T value, Transcoder<T> tc) {
  3. CachedData co = tc.encode(value);
  4. final CountDownLatch latch = new CountDownLatch(1);
  5. final OperationFuture<Boolean> rv = new OperationFuture<Boolean>(latch,
  6. operationTimeout);
  7. Operation op = opFact.store(storeType, key, co.getFlags(),
  8. exp, co.getData(), new OperationCallback() {
  9. public void receivedStatus(OperationStatus val) {
  10. rv.set(val.isSuccess());
  11. }
  12. public void complete() {
  13. latch.countDown();
  14. }
  15. });
  16. rv.setOperation(op);
  17. addOp(key, op);
  18. return rv;
  19. }

代码示例来源:origin: com.google.code.maven-play-plugin.spy/spymemcached

  1. }});
  2. rv.setOperation(op);
  3. addOp(key, op);
  4. return rv;

相关文章