本文整理汇总了Java中net.spy.memcached.internal.OperationFuture.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java OperationFuture.addListener方法的具体用法?Java OperationFuture.addListener怎么用?Java OperationFuture.addListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.spy.memcached.internal.OperationFuture
的用法示例。
在下文中一共展示了OperationFuture.addListener方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setKeyValueInCouchBase
import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
public void setKeyValueInCouchBase(T tuple)
{
id++;
String key = getKey(tuple);
Object value = getValue(tuple);
if (!(value instanceof Boolean) && !(value instanceof Integer) && !(value instanceof String) && !(value instanceof Float) && !(value instanceof Double) && !(value instanceof Character) && !(value instanceof Long) && !(value instanceof Short) && !(value instanceof Byte)) {
if (serializer != null) {
value = serializer.serialize(value);
}
}
OperationFuture<Boolean> future = processKeyValue(key, value);
synchronized (syncObj) {
future.addListener(listener);
mapFuture.put(future, id);
if (!mapTuples.containsKey(id)) {
mapTuples.put(id, tuple);
}
numTuples++;
}
}
示例2: removeData
import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
@Override
public void removeData(final String sessionId, final int pageId)
{
final Set<String> keys = keysPerSession.get(sessionId);
final String key = getKey(sessionId, pageId);
if (keys != null && keys.contains(key))
{
OperationFuture<Boolean> delete = client.delete(key);
delete.addListener(new OperationCompletionListener()
{
@Override
public void onComplete(OperationFuture<?> future) throws Exception
{
keys.remove(key);
LOG.debug("Removed the data for session '{}' and page id '{}'", sessionId, pageId);
}
});
}
}
示例3: main
import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException
{
final MemcachedClient c = new MemcachedClient(new InetSocketAddress("localhost", 11211));
Object o = c.get(KEY);
System.err.println("1. get: " + o);
OperationFuture<Boolean> add = c.add(KEY, 50000, "1");
add.addListener(new OperationCompletionListener()
{
@Override
public void onComplete(OperationFuture<?> operationFuture) throws Exception
{
Object o2 = c.get(KEY);
System.err.println("2. get: " + o2);
c.delete(KEY);
Object o3 = c.get(KEY);
System.err.println("3. get: " + o3);
c.shutdown();
}
});
}
示例4: EVCacheFutures
import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
public EVCacheFutures(OperationFuture<Boolean>[] futures, String key, String app, ServerGroup serverGroup, EVCacheLatch latch) {
this.futures = futures;
this.app = app;
this.serverGroup = serverGroup;
this.key = key;
this.latch = latch;
this.completionCounter = new AtomicInteger(futures.length);
if (latch != null && latch instanceof EVCacheLatchImpl) ((EVCacheLatchImpl) latch).addFuture(this);
for (int i = 0; i < futures.length; i++) {
final OperationFuture<Boolean> of = futures[i];
if (of.isDone()) {
try {
onComplete(of);
} catch (Exception e) {
}
} else {
of.addListener(this);
}
}
}