本文整理了Java中net.spy.memcached.MemcachedClient.incr()
方法的一些代码示例,展示了MemcachedClient.incr()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MemcachedClient.incr()
方法的具体详情如下:
包路径:net.spy.memcached.MemcachedClient
类名称:MemcachedClient
方法名:incr
[英]Increment the given key by the given amount. 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 incr(String key, int by) {
return client.incr(key, by, 0);
}
代码示例来源:origin: com.google.code.maven-play-plugin.org.playframework/play
@Override
public long incr(String key, int by) {
return client.incr(key, by, 0);
}
代码示例来源:origin: sixhours-team/memcached-spring-boot
@Override
public void clear() {
this.memcachedClient.incr(this.memcacheCacheMetadata.namespaceKey(), 1);
}
代码示例来源:origin: io.snappydata/gemfire-junit
public void testIncr() throws Exception {
MemcachedClient client = bootstrapClient();
client.add("incrkey", 10, 99).get();
assertEquals(104, client.incr("incrkey", 5));
assertEquals(105, client.incr("incrkey", 1));
assertEquals(-1, client.incr("inckey1", 10));
}
代码示例来源:origin: net.anthavio/hatatitla
/**
* Changing namespace by incrementing it's version results in (virtally) removing all entries means
* because namespace is part of key - all keys became invalid
*/
@Override
public void removeAll() throws IllegalStateException {
if (namespaceVersioning) {
String nsVersionKey = getNsVersionKey();
long incr = client.incr(nsVersionKey, 1);
if (incr == -1) {//nsVersion entry does not not exist -> create it
try {
Future<Boolean> future = client.set(nsVersionKey, DAY, VERSION_IN);
future.get(operationTimeout, TimeUnit.MILLISECONDS);
} catch (Exception x) {
logger.warn("Failed to removeAll", x);
}
}
logger.debug("Namespace version set to " + getName() + ":" + incr);
} else {
throw new IllegalStateException("Cannot remove all. Namespace versioning is not enabled.");
}
}
代码示例来源:origin: sixhours-team/memcached-spring-boot
@Test
public void whenClearThenMemcachedClientIncrNamespace() {
memcachedCache.clear();
verify(memcachedClient).incr(namespaceKey, 1);
}
}
代码示例来源:origin: aurorafeint/jruby-memcached
@JRubyMethod(name = { "increment", "incr" }, required = 1, optional = 2)
public IRubyObject incr(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.incr(key, by, 1, expiry);
return ruby.newFixnum(result);
} catch (OperationTimeoutException e) {
if (retry == exceptionRetryLimit) {
throw Error.newATimeoutOccurred(ruby, e.getLocalizedMessage());
}
retry++;
}
}
}
内容来源于网络,如有侵权,请联系作者删除!