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


Java Transcoder.encode方法代码示例

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


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

示例1: asyncStore

import net.spy.memcached.transcoders.Transcoder; //导入方法依赖的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

示例2: asyncCat

import net.spy.memcached.transcoders.Transcoder; //导入方法依赖的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

示例3: asyncCAS

import net.spy.memcached.transcoders.Transcoder; //导入方法依赖的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

示例4: BTreeBulkStore

import net.spy.memcached.transcoders.Transcoder; //导入方法依赖的package包/类
public BTreeBulkStore(List<String> keyList, long bkey, byte[] eflag,
		T value, CollectionAttributes attr, Transcoder<T> tc) {
	if (attr != null) {
		CollectionOverflowAction overflowAction = attr.getOverflowAction();
		if (overflowAction != null && !CollectionType.btree.isAvailableOverflowAction(overflowAction))
			throw new IllegalArgumentException(overflowAction + " is unavailable overflow action in " + CollectionType.btree + ".");
	}
	this.keyList = keyList;
	this.bkey = String.valueOf(bkey);
	this.eflag = BTreeUtil.toHex(eflag);
	this.value = value;
	this.attribute = attr;
	this.tc = tc;
	this.itemCount = keyList.size();
	this.createKeyIfNotExists = (attr != null);
	this.cachedData = tc.encode(value);
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:18,代码来源:CollectionBulkStore.java

示例5: MapBulkStore

import net.spy.memcached.transcoders.Transcoder; //导入方法依赖的package包/类
public MapBulkStore(List<String> keyList, String mkey, T value,
                    CollectionAttributes attr, Transcoder<T> tc) {
	if (attr != null) {
		CollectionOverflowAction overflowAction = attr.getOverflowAction();
		if (overflowAction != null && !CollectionType.map.isAvailableOverflowAction(overflowAction))
			throw new IllegalArgumentException(overflowAction + " is unavailable overflow action in " + CollectionType.map + ".");
	}
	this.keyList = keyList;
	this.mkey = mkey;
	this.value = value;
	this.attribute = attr;
	this.tc = tc;
	this.itemCount = keyList.size();
	this.createKeyIfNotExists = (attr != null);
	this.cachedData = tc.encode(value);
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:17,代码来源:CollectionBulkStore.java

示例6: ListBulkStore

import net.spy.memcached.transcoders.Transcoder; //导入方法依赖的package包/类
public ListBulkStore(List<String> keyList, int index, T value,
		CollectionAttributes attr, Transcoder<T> tc) {
	if (attr != null) {
		CollectionOverflowAction overflowAction = attr.getOverflowAction();
		if (overflowAction != null && !CollectionType.list.isAvailableOverflowAction(overflowAction))
			throw new IllegalArgumentException(overflowAction + " is unavailable overflow action in " + CollectionType.list + ".");
	}
	this.keyList = keyList;
	this.index = index;
	this.value = value;
	this.attribute = attr;
	this.tc = tc;
	this.itemCount = keyList.size();
	this.createKeyIfNotExists = (attr != null);
	this.cachedData = tc.encode(value);
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:17,代码来源:CollectionBulkStore.java

示例7: SetBulkStore

import net.spy.memcached.transcoders.Transcoder; //导入方法依赖的package包/类
public SetBulkStore(List<String> keyList, T value,
		CollectionAttributes attr, Transcoder<T> tc) {
	if (attr != null) {
		CollectionOverflowAction overflowAction = attr.getOverflowAction();
		if (overflowAction != null && !CollectionType.set.isAvailableOverflowAction(overflowAction))
			throw new IllegalArgumentException(overflowAction + " is unavailable overflow action in " + CollectionType.set + ".");
	}
	this.keyList = keyList;
	this.value = value;
	this.attribute = attr;
	this.tc = tc;
	this.itemCount = keyList.size();
	this.createKeyIfNotExists = (attr != null);
	this.cachedData = tc.encode(value);
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:16,代码来源:CollectionBulkStore.java

示例8: asyncCollectionUpsert

import net.spy.memcached.transcoders.Transcoder; //导入方法依赖的package包/类
private <T> CollectionFuture<Boolean> asyncCollectionUpsert(
		final String key, final String subkey,
		final CollectionStore<T> collectionStore, Transcoder<T> tc) {

	CachedData co = tc.encode(collectionStore.getValue());
	collectionStore.setFlags(co.getFlags());

	final CountDownLatch latch = new CountDownLatch(1);
	final CollectionFuture<Boolean> rv = new CollectionFuture<Boolean>(
			latch, operationTimeout);
	Operation op = opFact.collectionUpsert(key, subkey, collectionStore,
			co.getData(), new OperationCallback() {
				public void receivedStatus(OperationStatus status) {
					CollectionOperationStatus cstatus;

					if (status instanceof CollectionOperationStatus) {
						cstatus = (CollectionOperationStatus) status;
					} else {
						getLogger().warn("Unhandled state: " + status);
						cstatus = new CollectionOperationStatus(status);
					}
					rv.set(cstatus.isSuccess(), cstatus);
					if (!cstatus.isSuccess()
							&& getLogger().isDebugEnabled()) {
						getLogger().debug(
								"Insertion to the collection failed : "
										+ cstatus.getMessage()
										+ " (type="
										+ collectionStore.getClass()
												.getName() + ", key=" + key
										+ ", subkey=" + subkey + ", value="
										+ collectionStore.getValue() + ")");
					}
				}

				public void complete() {
					latch.countDown();
				}
			});
	rv.setOperation(op);
	addOp(key, op);
	return rv;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:44,代码来源:ArcusClient.java

示例9: asyncCollectionUpdate

import net.spy.memcached.transcoders.Transcoder; //导入方法依赖的package包/类
/**
 * Generic update operation for collection items. Public methods for collection items call this method.
 *
 * @param key  collection item's key
 * @param subkey  element key (list index, b+tree bkey)
 * @param collectionUpdate  operation parameters (element value and so on)
 * @param tc  transcoder to serialize and unserialize value
 * @return future holding the success/failure of the operation
 */
private <T> CollectionFuture<Boolean> asyncCollectionUpdate(
		final String key, final String subkey,
		final CollectionUpdate<T> collectionUpdate, Transcoder<T> tc) {

	CachedData co = null;
	if (collectionUpdate.getNewValue() != null) {
		co = tc.encode(collectionUpdate.getNewValue());
		collectionUpdate.setFlags(co.getFlags());
	}

	final CountDownLatch latch = new CountDownLatch(1);
	final CollectionFuture<Boolean> rv = new CollectionFuture<Boolean>(
			latch, operationTimeout);

	Operation op = opFact.collectionUpdate(key, subkey, collectionUpdate,
			((co == null) ? null : co.getData()), new OperationCallback() {
				public void receivedStatus(OperationStatus status) {
					CollectionOperationStatus cstatus;

					if (status instanceof CollectionOperationStatus) {
						cstatus = (CollectionOperationStatus) status;
					} else {
						getLogger().warn("Unhandled state: " + status);
						cstatus = new CollectionOperationStatus(status);
					}
					rv.set(cstatus.isSuccess(), cstatus);
					if (!cstatus.isSuccess()
							&& getLogger().isDebugEnabled()) {
						getLogger().debug(
								"Insertion to the collection failed : "
										+ cstatus.getMessage()
										+ " (type="
										+ collectionUpdate.getClass()
												.getName() + ", key=" + key
										+ ", subkey=" + subkey + ", value="
										+ collectionUpdate.getNewValue()
										+ ")");
					}
				}

				public void complete() {
					latch.countDown();
				}
			});
	rv.setOperation(op);
	addOp(key, op);
	return rv;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:58,代码来源:ArcusClient.java

示例10: asyncCollectionStore

import net.spy.memcached.transcoders.Transcoder; //导入方法依赖的package包/类
/**
 * Generic store operation for collection items. Public methods for collection items call this method.
 *
 * @param key  collection item's key
 * @param subkey  element key (list index, b+tree bkey)
 * @param collectionStore  operation parameters (value, eflags, attributes, and so on)
 * @param tc  transcoder to serialize and unserialize value
 * @return future holding the success/failure of the operation
 */
private <T> CollectionFuture<Boolean> asyncCollectionStore(String key,
		String subkey, CollectionStore<T> collectionStore, Transcoder<T> tc) {
	CachedData co = tc.encode(collectionStore.getValue());
	collectionStore.setFlags(co.getFlags());
	return asyncCollectionStore(key, subkey, collectionStore, co);
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:16,代码来源:ArcusClient.java


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