当前位置: 首页>>代码示例>>Java>>正文


Java OperationFuture.setOperation方法代码示例

本文整理汇总了Java中net.spy.memcached.internal.OperationFuture.setOperation方法的典型用法代码示例。如果您正苦于以下问题:Java OperationFuture.setOperation方法的具体用法?Java OperationFuture.setOperation怎么用?Java OperationFuture.setOperation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.spy.memcached.internal.OperationFuture的用法示例。


在下文中一共展示了OperationFuture.setOperation方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: asyncStore

import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
Future<Boolean> asyncStore(StoreType storeType, String key,
		int exp, CachedData co) {
	final CountDownLatch latch=new CountDownLatch(1);
	final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
			operationTimeout);
	Operation op=opFact.store(storeType, key, co.getFlags(),
			exp, co.getData(), new OperationCallback() {
		public void receivedStatus(OperationStatus val) {
			rv.set(val.isSuccess());
		}
		public void complete() {
			latch.countDown();
		}});
	rv.setOperation(op);
	addOp(key, op);
	return rv;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:18,代码来源:ArcusClient.java

示例2: asyncStore

import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
private <T> Future<Boolean> asyncStore(StoreType storeType, String key,
					   int exp, T value, Transcoder<T> tc) {
	CachedData co=tc.encode(value);
	final CountDownLatch latch=new CountDownLatch(1);
	final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
			operationTimeout);
	Operation op=opFact.store(storeType, key, co.getFlags(),
			exp, co.getData(), new OperationCallback() {
				public void receivedStatus(OperationStatus val) {
					rv.set(val.isSuccess());
				}
				public void complete() {
					latch.countDown();
				}});
	rv.setOperation(op);
	addOp(key, op);
	return rv;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:19,代码来源:MemcachedClient.java

示例3: asyncCat

import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
private <T> Future<Boolean> asyncCat(
		ConcatenationType catType, long cas, String key,
		T value, Transcoder<T> tc) {
	CachedData co=tc.encode(value);
	final CountDownLatch latch=new CountDownLatch(1);
	final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
			operationTimeout);
	Operation op=opFact.cat(catType, cas, key, co.getData(),
			new OperationCallback() {
		public void receivedStatus(OperationStatus val) {
			rv.set(val.isSuccess());
		}
		public void complete() {
			latch.countDown();
		}});
	rv.setOperation(op);
	addOp(key, op);
	return rv;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:20,代码来源:MemcachedClient.java

示例4: asyncCAS

import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
/**
 * Asynchronous CAS operation.
 *
 * @param <T>
 * @param key the key
 * @param casId the CAS identifier (from a gets operation)
 * @param exp the expiration of this object
 * @param value the new value
 * @param tc the transcoder to serialize and unserialize the value
 * @return a future that will indicate the status of the CAS
 * @throws IllegalStateException in the rare circumstance where queue
 *         is too full to accept any more requests
 */
public <T> Future<CASResponse> asyncCAS(String key, long casId, int exp, T value,
		Transcoder<T> tc) {
	CachedData co=tc.encode(value);
	final CountDownLatch latch=new CountDownLatch(1);
	final OperationFuture<CASResponse> rv=new OperationFuture<CASResponse>(
			latch, operationTimeout);
	Operation op=opFact.cas(StoreType.set, key, casId, co.getFlags(), exp,
			co.getData(), new OperationCallback() {
				public void receivedStatus(OperationStatus val) {
					if(val instanceof CASOperationStatus) {
						rv.set(((CASOperationStatus)val).getCASResponse());
					} else if(val instanceof CancelledOperationStatus) {
						rv.set(CASResponse.CANCELED);
					} else {
						rv.set(CASResponse.UNDEFINED);
					}
				}
				public void complete() {
					latch.countDown();
				}});
	rv.setOperation(op);
	addOp(key, op);
	return rv;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:38,代码来源:MemcachedClient.java

示例5: asyncMutate

import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
private Future<Long> asyncMutate(Mutator m, String key, int by, long def,
		int exp) {
	final CountDownLatch latch = new CountDownLatch(1);
	final OperationFuture<Long> rv = new OperationFuture<Long>(
			latch, operationTimeout);
	Operation op = addOp(key, opFact.mutate(m, key, by, def, exp,
			new OperationCallback() {
		public void receivedStatus(OperationStatus s) {
			rv.set(new Long(s.isSuccess() ? s.getMessage() : "-1"));
		}
		public void complete() {
			latch.countDown();
		}
	}));
	rv.setOperation(op);
	return rv;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:18,代码来源:MemcachedClient.java

示例6: delete

import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
/**
 * Delete the given key from the cache.
 *
 * @param key the key to delete
 * @return whether or not the operation was performed
 * @throws IllegalStateException in the rare circumstance where queue
 *         is too full to accept any more requests
 */
public Future<Boolean> delete(String key) {
	final CountDownLatch latch=new CountDownLatch(1);
	final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
		operationTimeout);
	DeleteOperation op=opFact.delete(key,
			new OperationCallback() {
				public void receivedStatus(OperationStatus s) {
					rv.set(s.isSuccess());
				}
				public void complete() {
					latch.countDown();
				}});
	rv.setOperation(op);
	addOp(key, op);
	return rv;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:25,代码来源:MemcachedClient.java

示例7: delete

import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
public OperationFuture<Boolean> delete(String key, EVCacheLatch evcacheLatch) {
    final CountDownLatch latch = new CountDownLatch(1);
    final OperationFuture<Boolean> rv = new OperationFuture<Boolean>(key, latch, connectionFactory.getOperationTimeout(), executorService);
    final Stopwatch operationDuration = getTimer(DELETE_STRING).start();
    final DeleteOperation.Callback callback = new DeleteOperation.Callback() {
        @Override
        public void receivedStatus(OperationStatus status) {
            operationDuration.stop();
            rv.set(Boolean.TRUE, status);
            if (status.getStatusCode().equals(StatusCode.SUCCESS)) {
                getCounter(DELETE_OPERATION_SUCCESS_STRING).increment();
            } else {
                getCounter("DeleteOperation-"+ status.getStatusCode().name()).increment();
            }
        }

        @Override
        public void gotData(long cas) {
            rv.setCas(cas);
        }

        @Override
        public void complete() {
            latch.countDown();
            rv.signalComplete();
        }
    };

    final DeleteOperation op = opFact.delete(key, callback);
    rv.setOperation(op);
    if (evcacheLatch != null && evcacheLatch instanceof EVCacheLatchImpl && !client.isInWriteOnly()) ((EVCacheLatchImpl) evcacheLatch).addFuture(rv);
    mconn.enqueueOperation(key, op);
    return rv;
}
 
开发者ID:Netflix,项目名称:EVCache,代码行数:35,代码来源:EVCacheMemcachedClient.java

示例8: touch

import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
public <T> OperationFuture<Boolean> touch(final String key, final int exp, EVCacheLatch evcacheLatch) {
    final CountDownLatch latch = new CountDownLatch(1);
    final OperationFuture<Boolean> rv = new OperationFuture<Boolean>(key, latch, connectionFactory.getOperationTimeout(), executorService);
    final Stopwatch operationDuration = getTimer(TOUCH_OPERATION_STRING).start();
    Operation op = opFact.touch(key, exp, new OperationCallback() {
        @Override
        public void receivedStatus(OperationStatus status) {
            operationDuration.stop();
            rv.set(status.isSuccess(), status);

            if (status.getStatusCode().equals(StatusCode.SUCCESS)) {
                getCounter(TOUCH_OPERATION_SUCCESS_STRING).increment();
            } else {
                getCounter(TOUCH_OPERATION_STRING + "-" + status.getStatusCode().name()).increment();
            }
        }

        @Override
        public void complete() {
            latch.countDown();
            rv.signalComplete();
        }
    });
    rv.setOperation(op);
    if (evcacheLatch != null && evcacheLatch instanceof EVCacheLatchImpl && !client.isInWriteOnly()) ((EVCacheLatchImpl) evcacheLatch).addFuture(rv);
    mconn.enqueueOperation(key, op);
    return rv;
}
 
开发者ID:Netflix,项目名称:EVCache,代码行数:29,代码来源:EVCacheMemcachedClient.java


注:本文中的net.spy.memcached.internal.OperationFuture.setOperation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。