memcached 的java 客户端的简单测试代码

xiaoxiao2026-09-12  11

import java.io.IOException; import java.net.InetSocketAddress; import net.spy.memcached.MemcachedClient; public class MemMain { public static void main(String[] args) throws IOException { MemcachedClient c=new MemcachedClient( new InetSocketAddress("127.0.0.1", 12000)); for(int i=1;i<10;i++){ c.set("T0001"+i, 3600, new User(i+"")); } // Store a value (async) for one hour // Retrieve a value (synchronously). User myObject=(User)c.get("T00011"); System.out.println("get object from mem :"+myObject); } } import java.io.Serializable; public class User implements Serializable{ public String getUserId() { return userId; } public void setUserId(String userId) { this.userId = userId; } public User(String userId) { super(); this.userId = userId; } String userId; @Override public String toString() { // TODO Auto-generated method stub StringBuffer sb=new StringBuffer(); sb.append("userId="+this.userId); return sb.toString(); } } 相关资源:敏捷开发V1.0.pptx
转载请注明原文地址: https://www.6miu.com/read-5052564.html

最新回复(0)