本文整理匯總了Java中net.spy.memcached.ops.GetAndTouchOperation類的典型用法代碼示例。如果您正苦於以下問題:Java GetAndTouchOperation類的具體用法?Java GetAndTouchOperation怎麽用?Java GetAndTouchOperation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GetAndTouchOperation類屬於net.spy.memcached.ops包,在下文中一共展示了GetAndTouchOperation類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getOperationName
import net.spy.memcached.ops.GetAndTouchOperation; //導入依賴的package包/類
public static <T extends Operation> String getOperationName(T operation) {
//TODO optimize. Convert multiple if/else to switch or map.get()
String op;
if (operation instanceof StoreOperation) {
op = ((StoreOperation) operation).getStoreType().name();
} else if (operation instanceof ConcatenationOperation) {
op = ((ConcatenationOperation) operation).getStoreType().name();
} else if (operation instanceof GetsOperation) {
op = "get";
} else if (operation instanceof GetOperation) {
op = "get";
} else if (operation instanceof GetAndTouchOperation) {
op = "gat";
} else if (operation instanceof MutatorOperation) {
op = ((MutatorOperation) operation).getType().name();
} else {
op = Operations.getOperationName(operation.getClass());
}
return op;
}
示例2: decodePayload
import net.spy.memcached.ops.GetAndTouchOperation; //導入依賴的package包/類
@Override
protected void decodePayload(byte[] pl) {
final int flags = decodeInt(pl, 0);
final byte[] data = new byte[pl.length - EXTRA_HDR_LEN];
System.arraycopy(pl, EXTRA_HDR_LEN, data, 0, pl.length - EXTRA_HDR_LEN);
GetAndTouchOperation.Callback gcb =
(GetAndTouchOperation.Callback) getCallback();
gcb.gotData(key, flags, responseCas, data);
getCallback().receivedStatus(STATUS_OK);
}
示例3: asyncGetAndTouch
import net.spy.memcached.ops.GetAndTouchOperation; //導入依賴的package包/類
public <T> EVCacheOperationFuture<CASValue<T>> asyncGetAndTouch(final String key, final int exp, final Transcoder<T> tc) {
final CountDownLatch latch = new CountDownLatch(1);
final EVCacheOperationFuture<CASValue<T>> rv = new EVCacheOperationFuture<CASValue<T>>(key, latch, new AtomicReference<CASValue<T>>(null), connectionFactory.getOperationTimeout(), executorService, appName, serverGroup);
final Stopwatch operationDuration = getTimer(GET_AND_TOUCH_OPERATION_STRING).start();
Operation op = opFact.getAndTouch(key, exp, new GetAndTouchOperation.Callback() {
private CASValue<T> val = null;
public void receivedStatus(OperationStatus status) {
operationDuration.stop();
rv.set(val, status);
}
public void complete() {
latch.countDown();
rv.signalComplete();
}
public void gotData(String k, int flags, long cas, byte[] data) {
if (!key.equals(k)) log.warn("Wrong key returned. Key - {}; Returned Key {}", key, k);
if (data != null) {
if(getAndTouchDataSize == null) getAndTouchDataSize = EVCacheMetricsFactory.getDistributionSummary(appName + "-GATOperation-DataSize", appName, serverGroup.getName());
if (getAndTouchDataSize != null) getAndTouchDataSize.record(data.length);
}
val = new CASValue<T>(cas, tc.decode(new CachedData(flags, data, tc.getMaxSize())));
}
});
rv.setOperation(op);
mconn.enqueueOperation(key, op);
return rv;
}
示例4: GetAndTouchOperationImpl
import net.spy.memcached.ops.GetAndTouchOperation; //導入依賴的package包/類
public GetAndTouchOperationImpl(String k, int e,
GetAndTouchOperation.Callback cb) {
super(GAT_CMD, generateOpaque(), k, cb);
exp = e;
}
示例5: getAndTouch
import net.spy.memcached.ops.GetAndTouchOperation; //導入依賴的package包/類
public GetAndTouchOperation getAndTouch(String key, int expiration,
GetAndTouchOperation.Callback cb) {
return new GetAndTouchOperationImpl(key, expiration, cb);
}
示例6: GetAndTouchOperationImpl
import net.spy.memcached.ops.GetAndTouchOperation; //導入依賴的package包/類
public GetAndTouchOperationImpl(String c, int e,
GetAndTouchOperation.Callback cb, String k) {
super(c, e, cb, k);
}
示例7: getAndTouch
import net.spy.memcached.ops.GetAndTouchOperation; //導入依賴的package包/類
public GetAndTouchOperation getAndTouch(String key, int expiration,
GetAndTouchOperation.Callback cb) {
throw new UnsupportedOperationException("Get and touch is not supported "
+ "for ASCII protocol");
}
示例8: getAndTouch
import net.spy.memcached.ops.GetAndTouchOperation; //導入依賴的package包/類
/**
* Gets the value of a key and resets its timeout.
*
* @param key the key to get a value for and reset its timeout
* @param expiration the new expiration for the key
* @param cb the callback that will contain the result
* @return a new GATOperation
*/
GetAndTouchOperation getAndTouch(String key, int expiration,
GetAndTouchOperation.Callback cb);