本文整理汇总了Java中net.spy.memcached.internal.GetFuture类的典型用法代码示例。如果您正苦于以下问题:Java GetFuture类的具体用法?Java GetFuture怎么用?Java GetFuture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GetFuture类属于net.spy.memcached.internal包,在下文中一共展示了GetFuture类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: get
import net.spy.memcached.internal.GetFuture; //导入依赖的package包/类
public Object get(String key)
{
if (! isActive())
return null;
Object result = null;
final GetFuture<Object> f = memcachedClient.get().asyncGet(key);
try
{
result = f.get(TIMEOUT, TimeUnit.MILLISECONDS);
}
catch (Exception e)
{
f.cancel(true);
}
return result;
// return memcachedClient.get(key); // sync version
}
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:19,代码来源:CacheHelper.java
示例2: shouldGetItem
import net.spy.memcached.internal.GetFuture; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void shouldGetItem() throws InterruptedException, TimeoutException, ExecutionException {
// Given
final String key = Randoms.randomString();
final String item = Randoms.randomString();
final int timeout = Randoms.randomInt(5) + 1;
final GetFuture<Object> f = mock(GetFuture.class);
when(memcachedClient.asyncGet(key)).thenReturn(f);
when(f.get(timeout, TimeUnit.SECONDS)).thenReturn(item);
// When
final Object obj = memcachedItemCache.getItem(key, timeout);
// Then
assertEquals(item, obj);
}
开发者ID:travel-cloud,项目名称:Cheddar,代码行数:18,代码来源:MemcachedItemCacheTest.java
示例3: shouldNotGetItem_throwsTimeout
import net.spy.memcached.internal.GetFuture; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void shouldNotGetItem_throwsTimeout() throws InterruptedException, ExecutionException, TimeoutException {
// Given
final String key = Randoms.randomString();
final int timeout = Randoms.randomInt(5) + 1;
final GetFuture<Object> f = mock(GetFuture.class);
when(memcachedClient.asyncGet(key)).thenReturn(f);
when(f.get(timeout, TimeUnit.SECONDS)).thenThrow(TimeoutException.class);
// When
final Object item = memcachedItemCache.getItem(key, timeout);
// Then
assertNull(item);
}
开发者ID:travel-cloud,项目名称:Cheddar,代码行数:17,代码来源:MemcachedItemCacheTest.java
示例4: get
import net.spy.memcached.internal.GetFuture; //导入依赖的package包/类
private Object get(String key) {
GetFuture<Object> future = client.asyncGet(key);
try {
return future.get(config.getCacheGetTimeoutInMillis(), TimeUnit.MILLISECONDS);
} catch(Exception e) {
log.warn("{\"method\":\"get\",\"exception\":\"{}\",\"message\":\"Exception whilst attempting get from memcached for key\",\"key\":\"{}\"}",e.getMessage(),key);
return null;
}
}
开发者ID:tootedom,项目名称:tomcat-memcached-response-filter,代码行数:10,代码来源:SpyFilterMemcachedFetching.java
示例5: get
import net.spy.memcached.internal.GetFuture; //导入依赖的package包/类
@Override
public void get(String key, CountDownLatch countDownLatch) throws Exception {
((GetFuture<Object>) client.asyncGet(key))
.addListener(future -> countDownLatch.countDown());
}
开发者ID:eranharel,项目名称:memcached-java-clients-benchmark,代码行数:6,代码来源:MemcachedClientsBenchmark.java
示例6: asyncGet
import net.spy.memcached.internal.GetFuture; //导入依赖的package包/类
public <T> GetFuture<T> asyncGet(final String key, final Transcoder<T> tc) {
throw new UnsupportedOperationException("asyncGet");
}
开发者ID:Netflix,项目名称:EVCache,代码行数:4,代码来源:EVCacheMemcachedClient.java
示例7: asyncGet
import net.spy.memcached.internal.GetFuture; //导入依赖的package包/类
/**
* 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);
}
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:12,代码来源:MemcachedClient.java
注:本文中的net.spy.memcached.internal.GetFuture类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论