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

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

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

MemcachedClient.decr介绍

[英]Decrement the given key by the given value. Due to the way the memcached server operates on items, incremented and decremented items will be returned as Strings with any operations that return a value.
[中]按给定值递减给定键。由于memcached服务器对项目的操作方式,递增和递减的项目将作为字符串返回,任何操作都会返回一个值。

代码示例

代码示例来源:origin: ninjaframework/ninja

public long decr(String key, int by) {
  return client.decr(key, by, 0);
}

代码示例来源:origin: Netflix/EVCache

public long decr(String key, long by, long def, int exp) {
  final Stopwatch operationDuration = getTimer(DECR_OPERATION_STRING).start();
  long val = 0;
  try {
    val = super.decr(key, by, def, exp);
  } finally {
    operationDuration.stop();
    if (log.isDebugEnabled()) log.debug("decrement Key : " + key + "; by : " + by + "; default : " + def + "; exp : " + exp 
        + "; val : " + val + "; Elapsed Time - " + (operationDuration.getDuration(TimeUnit.MILLISECONDS)));
  }
  return val;
}

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

@Override
public long decr(String key, int by) {
  return client.decr(key, by, 0);
}

代码示例来源:origin: io.snappydata/gemfire-junit

public void testDecr() throws Exception {
 MemcachedClient client = bootstrapClient();
 client.add("decrkey", 10, 99).get();
 assertEquals(95, client.decr("decrkey", 4));
 assertEquals(94, client.decr("decrkey", 1));
 assertEquals(-1, client.decr("decrkey1", 77));
}

代码示例来源:origin: io.snappydata/gemfire-junit

@Override
public void testDecr() throws Exception {
 super.testDecr();
 MemcachedClient client = createMemcachedClient();
 assertEquals(0, client.decr("decrkey", 999));
}

代码示例来源:origin: aurorafeint/jruby-memcached

@JRubyMethod(name = { "decrement", "decr" }, required = 1, optional = 2)
public IRubyObject decr(ThreadContext context, IRubyObject[] args) {
  Ruby ruby = context.getRuntime();
  String key = getFullKey(args[0].toString());
  int by = getIncrDecrBy(args);
  int expiry = getExpiry(args);
  int retry = 0;
  while (true) {
    try {
      long result = client.decr(key, by, 0, expiry);
      return ruby.newFixnum(result);
    } catch (OperationTimeoutException e) {
      if (retry == exceptionRetryLimit) {
        throw Error.newATimeoutOccurred(ruby, e.getLocalizedMessage());
      }
      retry++;
    }
  }
}

相关文章