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


Java Transcoder类代码示例

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


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

示例1: cas

import net.spy.memcached.transcoders.Transcoder; //导入依赖的package包/类
/**
 * Method to allow CAS 
 * @param <T>
 * @param key
 * @param mutation
 * @param value
 * @return
 */
public <T> T cas(String key,CASMutation<T> mutation,T value,int expireSecs)
{
	Transcoder transcoder = new SerializingTranscoder();
	// The mutator who'll do all the low-level stuff.
	// Set number of retries to limit time taken..its not essential this succeeds
	CASMutator<T> mutator = new CASMutator<>(memcachedClient, transcoder,MAX_CAS_RETRIES);

	// This returns whatever value was successfully stored within the
	// cache -- either the initial list as above, or a mutated existing
	// one
	try 
	{
		return mutator.cas(hashKey(key), value, expireSecs, mutation);
	} 
	catch (Exception e) 
	{
		logger.error("Failed up update hits in cache ",e);
		return null;
	}
}
 
开发者ID:SeldonIO,项目名称:seldon-server,代码行数:29,代码来源:ExceptionSwallowingMemcachedClient.java

示例2: asyncMopInsertBulk

import net.spy.memcached.transcoders.Transcoder; //导入依赖的package包/类
@Override
public <T> Future<Map<String, CollectionOperationStatus>> asyncMopInsertBulk(
		List<String> keyList, String mkey, T value,
		CollectionAttributes attributesForCreate, Transcoder<T> tc) {

	validateMKey(mkey);
	Map<String, List<String>> arrangedKey = groupingKeys(keyList, NON_PIPED_BULK_INSERT_CHUNK_SIZE);

	List<CollectionBulkStore<T>> storeList = new ArrayList<CollectionBulkStore<T>>(
			arrangedKey.size());

	for (List<String> eachKeyList : arrangedKey.values()) {
		storeList.add(new CollectionBulkStore.MapBulkStore<T>(
				eachKeyList, mkey, value, attributesForCreate, tc));
	}

	return asyncCollectionInsertBulk2(storeList);
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:19,代码来源:ArcusClient.java

示例3: makeBTreeElement

import net.spy.memcached.transcoders.Transcoder; //导入依赖的package包/类
/**
 * Utility method to create a b+tree element from individual parameters.
 *
 * @param key  b+tree item's key
 * @param flags  item flags, used when creating the item (see createKeyIfNotExists)
 * @param bkey  element key
 * @param eflag  element flags
 * @param value  element value
 * @param tc  transcoder to serialize and unserialize value
 * @return element object containing all the parameters and transcoded value
 */
private <T> Element<T> makeBTreeElement(String key, int flags,
		BKeyObject bkey, byte[] eflag, byte[] data, Transcoder<T> tc) {
	Element<T> element = null;
	T value = tc.decode(new CachedData(flags, data, tc.getMaxSize()));

	switch (bkey.getType()) {
	case LONG:
		element = new Element<T>(bkey.getLongBKey(), value, eflag);
		break;
	case BYTEARRAY:
		element = new Element<T>(bkey.getByteArrayBKeyRaw(), value, eflag);
		break;
	default:
		getLogger().error(
				"Unexpected bkey type : (key:" + key + ", bkey:"
						+ bkey.toString() + ")");
	}

	return element;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:32,代码来源:ArcusClient.java

示例4: 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

示例5: getBulkAsync

import net.spy.memcached.transcoders.Transcoder; //导入依赖的package包/类
@Override
public ComposableFuture<Map<K, V>> getBulkAsync(final Iterable<? extends K> keys) {
  final List<String> stringKeys = new ArrayList<>();
  final Map<String, K> keysMap = new HashMap<>();
  try {
    for (final K key : keys) {
      final String stringKey = keyTranslator.translateKey(key);
      stringKeys.add(stringKey);
      keysMap.put(stringKey, key);
    }

    return SpyFutureHelper.fromBulkGet(() -> {
      @SuppressWarnings("unchecked")
      final Transcoder<V> transcoder = (Transcoder<V>) spyClient.getTranscoder();
      return spyClient.asyncGetBulk(stringKeys, transcoder);
    }, keysMap);

  } catch (final Exception e) {
    return fromError(e);
  }
}
 
开发者ID:outbrain,项目名称:ob1k,代码行数:22,代码来源:MemcacheClient.java

示例6: 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

示例7: asyncSopInsertBulk

import net.spy.memcached.transcoders.Transcoder; //导入依赖的package包/类
@Override
public <T> Future<Map<String, CollectionOperationStatus>> asyncSopInsertBulk(
		List<String> keyList, T value,
		CollectionAttributes attributesForCreate, Transcoder<T> tc) {

	Map<String, List<String>> arrangedKey = groupingKeys(keyList, NON_PIPED_BULK_INSERT_CHUNK_SIZE);
	List<CollectionBulkStore<T>> storeList = new ArrayList<CollectionBulkStore<T>>(
			arrangedKey.size());

	for (List<String> eachKeyList : arrangedKey.values()) {
		storeList.add(new CollectionBulkStore.SetBulkStore<T>(
				eachKeyList, value, attributesForCreate, tc));
	}

	return asyncCollectionInsertBulk2(storeList);
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:17,代码来源:ArcusClient.java

示例8: asyncBopInsertBulk

import net.spy.memcached.transcoders.Transcoder; //导入依赖的package包/类
@Override
public <T> Future<Map<String, CollectionOperationStatus>> asyncBopInsertBulk(
		List<String> keyList, byte[] bkey, byte[] eFlag, T value,
		CollectionAttributes attributesForCreate, Transcoder<T> tc) {

	Map<String, List<String>> arrangedKey = groupingKeys(keyList, NON_PIPED_BULK_INSERT_CHUNK_SIZE);
	List<CollectionBulkStore<T>> storeList = new ArrayList<CollectionBulkStore<T>>(
			arrangedKey.size());

	for (List<String> eachKeyList : arrangedKey.values()) {
		storeList.add(new CollectionBulkStore.BTreeBulkStore<T>(
				eachKeyList, bkey, eFlag, value, attributesForCreate, tc));
	}

	return asyncCollectionInsertBulk2(storeList);
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:17,代码来源:ArcusClient.java

示例9: asyncLopInsertBulk

import net.spy.memcached.transcoders.Transcoder; //导入依赖的package包/类
@Override
public <T> Future<Map<String, CollectionOperationStatus>> asyncLopInsertBulk(
		List<String> keyList, int index, T value,
		CollectionAttributes attributesForCreate, Transcoder<T> tc) {

	Map<String, List<String>> arrangedKey = groupingKeys(keyList, NON_PIPED_BULK_INSERT_CHUNK_SIZE);
	List<CollectionBulkStore<T>> storeList = new ArrayList<CollectionBulkStore<T>>(
			arrangedKey.size());

	for (List<String> eachKeyList : arrangedKey.values()) {
		storeList.add(new CollectionBulkStore.ListBulkStore<T>(
				eachKeyList, index, value, attributesForCreate, tc));
	}

	return asyncCollectionInsertBulk2(storeList);
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:17,代码来源:ArcusClient.java

示例10: BaseCacheMap

import net.spy.memcached.transcoders.Transcoder; //导入依赖的package包/类
/**
 * Build a BaseCacheMap.
 *
 * @param c the underlying client
 * @param expiration the expiration for objects set through this Map
 * @param prefix a prefix to ensure objects in this map are unique
 * @param t the transcoder to serialize and deserialize objects
 */
public BaseCacheMap(MemcachedClientIF c, int expiration, String prefix,
    Transcoder<V> t) {
  super();
  keyPrefix = prefix;
  transcoder = t;
  client = c;
  exp = expiration;
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:17,代码来源:BaseCacheMap.java

示例11: cas

import net.spy.memcached.transcoders.Transcoder; //导入依赖的package包/类
/**
 * Method to allow CAS 
 * @param <T>
 * @param key
 * @param mutation
 * @param value
 * @return
 */
public static <T> T cas(String key,CASMutation<T> mutation,T value,int expireSecs)
{
	MemcachedClient client = getClient();
	 if (client != null)
	 {
		 Transcoder transcoder = new SerializingTranscoder();
		 // The mutator who'll do all the low-level stuff.
		 // Set number of retries to limit time taken..its not essential this succeeds
		 CASMutator<T> mutator = new CASMutator<>(client, transcoder,MAX_CAS_RETRIES);

		 // This returns whatever value was successfully stored within the
		 // cache -- either the initial list as above, or a mutated existing
		 // one
		 try 
		 {
			 return mutator.cas(hashKey(key), value, expireSecs, mutation);
		 } 
		 catch (Exception e) 
		 {
			 logger.error("Failed up update hits in cache ",e);
			 return null;
		 }
	 }
	 else
		 return null;
}
 
开发者ID:SeldonIO,项目名称:seldon-server,代码行数:35,代码来源:MemCachePeer.java

示例12: testGetBulkVarargWithTranscoder

import net.spy.memcached.transcoders.Transcoder; //导入依赖的package包/类
public void testGetBulkVarargWithTranscoder() throws Exception {
	Transcoder<String> t=new TestTranscoder();
	assertEquals(0, client.getBulk(t, "test1", "test2", "test3").size());
	client.set("test1", 5, "val1", t);
	client.set("test2", 5, "val2", t);
	Map<String, String> vals=client.getBulk(t, "test1", "test2", "test3");
	assertEquals(2, vals.size());
	assertEquals("val1", vals.get("test1"));
	assertEquals("val2", vals.get("test2"));
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:11,代码来源:ProtocolBaseCase.java

示例13: asyncMopUpdate

import net.spy.memcached.transcoders.Transcoder; //导入依赖的package包/类
@Override
public <T> CollectionFuture<Boolean> asyncMopUpdate(String key, String mkey,
		T value, Transcoder<T> tc) {
	validateMKey(mkey);
	MapUpdate<T> collectionUpdate = new MapUpdate<T>(value, false);
	return asyncCollectionUpdate(key, String.valueOf(mkey),
			collectionUpdate, tc);
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:9,代码来源:ArcusClient.java

示例14: getTranscoder

import net.spy.memcached.transcoders.Transcoder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T> Transcoder<T> getTranscoder(final CacheTranscoder transcoder) {
    Transcoder<T> transcoderAdapter = (Transcoder<T>) adapters.get(transcoder);
    if (transcoderAdapter == null) {
        transcoderAdapter = (Transcoder<T>) new TranscoderAdapter(transcoder);
        adapters.put(transcoder, transcoderAdapter);
    }

    return transcoderAdapter;
}
 
开发者ID:ragnor,项目名称:simple-spring-memcached,代码行数:11,代码来源:MemcacheClientWrapper.java

示例15: MapPipedUpdate

import net.spy.memcached.transcoders.Transcoder; //导入依赖的package包/类
public MapPipedUpdate(String key, Map<String, T> elements,
                      Transcoder<T> tc) {
	this.key = key;
	this.elements = elements;
	this.tc = tc;
	this.itemCount = elements.size();
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:8,代码来源:CollectionPipedUpdate.java


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