本文整理汇总了Java中net.spy.memcached.MemcachedClient.set方法的典型用法代码示例。如果您正苦于以下问题:Java MemcachedClient.set方法的具体用法?Java MemcachedClient.set怎么用?Java MemcachedClient.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.spy.memcached.MemcachedClient
的用法示例。
在下文中一共展示了MemcachedClient.set方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import net.spy.memcached.MemcachedClient; //导入方法依赖的package包/类
public static void main(String[] args) {
try{
// 连接本地的 Memcached 服务
MemcachedClient mcc = new MemcachedClient(new InetSocketAddress("172.18.3.34", 9101));
System.out.println("Connection to server sucessful.");
// 添加数据
Future fo = mcc.set("runoob", 900, "Free Education");
// 输出执行 set 方法后的状态
System.out.println("set status:" + fo.get());
// 使用 get 方法获取数据
System.out.println("runoob value in cache - " + mcc.get("runoob"));
// 关闭连接
mcc.shutdown();
}catch(Exception ex) {
System.out.println(ex.getMessage());
}
}
示例2: setValue
import net.spy.memcached.MemcachedClient; //导入方法依赖的package包/类
public static void setValue() {
try {
/* 建立MemcachedClient 实例,并指定memcached服务的IP地址和端口号 */
MemcachedClient mc = new MemcachedClient(new InetSocketAddress(hostname, port));
Future<Boolean> b = null;
/* 将key值,过期时间(秒)和要缓存的对象set到memcached中 */
b = mc.set("neead", 900, "someObject");
if (b.get()) {
mc.shutdown();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例3: put
import net.spy.memcached.MemcachedClient; //导入方法依赖的package包/类
public static void put(String key,Object obj)
{
MemcachedClient client = getClient();
if (client != null)
try
{
client.set(hashKey(key), 0, obj);
}
catch (Exception ex)
{
logger.error("Memcache put exeption ",ex);
}
}
示例4: testSet
import net.spy.memcached.MemcachedClient; //导入方法依赖的package包/类
public void testSet() throws Exception {
MemcachedClient client = bootstrapClient();
Future<Boolean> f = client.set("key", 10, "myStringValue");
assertTrue(f.get());
}
示例5: setInternal
import net.spy.memcached.MemcachedClient; //导入方法依赖的package包/类
static void setInternal(MemcachedClient mc, String KEY_PREFIX, int
KEY_EXPIRY, INode inode){
mc.set(getKey(KEY_PREFIX, inode), KEY_EXPIRY, inode.getId());
}