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


Java MemcachedClient.add方法代码示例

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


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

示例1: testGemFireProperty

import net.spy.memcached.MemcachedClient; //导入方法依赖的package包/类
public void testGemFireProperty() throws Exception {
  Properties props = new Properties();
  final int port = AvailablePortHelper.getRandomAvailableTCPPort();
  props.setProperty("memcached-port", port+"");
  CacheFactory cf = new CacheFactory(props);
  Cache cache = cf.create();
  
  MemcachedClient client = new MemcachedClient(
      new InetSocketAddress(SocketCreator.getLocalHost(), port));
  Future<Boolean> f = client.add("key", 10, "myStringValue");
  assertTrue(f.get());
  Future<Boolean> f1 = client.add("key1", 10, "myStringValue1");
  assertTrue(f1.get());
  
  assertEquals("myStringValue", client.get("key"));
  assertEquals("myStringValue1", client.get("key1"));
  assertNull(client.get("nonExistentkey"));
  cache.close();
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:20,代码来源:IntegrationJUnitTest.java

示例2: main

import net.spy.memcached.MemcachedClient; //导入方法依赖的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();
		}
	});
}
 
开发者ID:martin-g,项目名称:wicket-memcached-data-store,代码行数:24,代码来源:TestHomePage.java

示例3: testGetPutDomainObject

import net.spy.memcached.MemcachedClient; //导入方法依赖的package包/类
public void testGetPutDomainObject() throws Exception {
  MemcachedClient client = new MemcachedClient(
      new InetSocketAddress(SocketCreator.getLocalHost(), PORT));
  Customer c = new Customer("name0", "addr0");
  Customer c1 = new Customer("name1", "addr1");
  Future<Boolean> f = client.add("keyObj", 10, c);
  assertTrue(f.get());
  Future<Boolean> f1 = client.add("key1", 10, c1);
  assertTrue(f1.get());
  assertEquals(c, client.get("keyObj"));
  assertEquals(c1, client.get("key1"));
  assertNull(client.get("nonExistentkey"));
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:14,代码来源:DomainObjectsAsValuesJUnitTest.java

示例4: testPutGet

import net.spy.memcached.MemcachedClient; //导入方法依赖的package包/类
public void testPutGet() throws Exception {
  MemcachedClient client = createMemcachedClient();
  Future<Boolean> f = client.add("key", 10, "myStringValue");
  assertTrue(f.get());
  Future<Boolean> f1 = client.add("key1", 10, "myStringValue1");
  assertTrue(f1.get());
  assertEquals("myStringValue", client.get("key"));
  assertEquals("myStringValue1", client.get("key1"));
  assertNull(client.get("nonExistentkey"));
  // zero exp
  f = client.add("Hello", 0, "World");
  Thread.sleep(1100);
  assertEquals("World", client.get("Hello"));
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:15,代码来源:GemcachedDevelopmentJUnitTest.java

示例5: testMultiGet

import net.spy.memcached.MemcachedClient; //导入方法依赖的package包/类
public void testMultiGet() throws Exception {
  MemcachedClient client = bootstrapClient();
  Map<String, Object> val = client.getBulk("key", "key1");
  assertEquals(2, val.size());
  assertEquals("myStringValue", val.get("key"));
  assertEquals("myStringValue1", val.get("key1"));
  client.add("Hello", 0, "World");
  Thread.sleep(1100);
  assertEquals("World", client.get("Hello"));
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:11,代码来源:GemcachedDevelopmentJUnitTest.java

示例6: bootstrapClient

import net.spy.memcached.MemcachedClient; //导入方法依赖的package包/类
private MemcachedClient bootstrapClient() throws IOException,
    UnknownHostException, InterruptedException, ExecutionException {
  MemcachedClient client = createMemcachedClient();
  Future<Boolean> f = client.add("key", 10, "myStringValue");
  f.get();
  Future<Boolean> f1 = client.add("key1", 10, "myStringValue1");
  f1.get();
  return client;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:10,代码来源:GemcachedDevelopmentJUnitTest.java

示例7: testAdd

import net.spy.memcached.MemcachedClient; //导入方法依赖的package包/类
public void testAdd() throws Exception {
  MemcachedClient client = bootstrapClient();
  Future<Boolean> f = client.add("key", 10, "newVal");
  assertFalse(f.get());
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:6,代码来源:GemcachedDevelopmentJUnitTest.java

示例8: testLongExpiration

import net.spy.memcached.MemcachedClient; //导入方法依赖的package包/类
public void testLongExpiration() throws Exception {
  MemcachedClient client = bootstrapClient();
  client.add("newKey", (int)System.currentTimeMillis() - 60 *1000, "newValue");
  Thread.sleep(15 *1000);
  assertEquals("newValue", client.get("newKey"));
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:7,代码来源:GemcachedDevelopmentJUnitTest.java


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