登录 注册
当前位置:主页 > 资源下载 > 9 > java连memcached的驱动 spymemcached-2.10.3.jar下载

java连memcached的驱动 spymemcached-2.10.3.jar下载

  • 更新:2024-05-17 15:41:56
  • 大小:394KB
  • 推荐:★★★★★
  • 来源:网友上传分享
  • 类别:Memcached - 数据库
  • 格式:RAR

资源介绍

import java.net.InetSocketAddress; import java.util.concurrent.Future; import net.spy.memcached.MemcachedClient; public class MemcachedJava { public static void main(String[] args) { try{ // 连接本地的 Memcached 服务 MemcachedClient mcc = new MemcachedClient(new InetSocketAddress("127.0.0.1", 11211)); System.out.println("Connection to server sucessful."); // 添加数据 Future fo = mcc.set("runoob", 900, "Free Education"); // 打印状态 System.out.println("set status:" + fo.get()); // 输出 System.out.println("runoob value in cache - " + mcc.get("runoob")); // 添加 fo = mcc.add("runoob", 900, "memcached"); // 打印状态 System.out.println("add status:" + fo.get()); // 添加新key fo = mcc.add("codingground", 900, "All Free Compilers"); // 打印状态 System.out.println("add status:" + fo.get()); // 输出 System.out.println("codingground value in cache - " + mcc.get("codingground")); // 关闭连接 mcc.shutdown(); }catch(Exception ex){ System.out.println(ex.getMessage()); } } }