Memcached(一)在Windows上安装和测试memcached
1)下载memcached的windows安装程序
memcached-1.2.4-Win32-Preview-20080309_bin.zip 或其他版本
2)解压memcached 用管理员身份运行cmd.exe cd到解压目录下 执行 memcached.exe -d install 安装memcached
3)启动memcached memcached.exe -d start
然后测试程序
package com.guowuxin.memcached; import java.io.IOException;
import java.net.InetSocketAddress; import net.spy.memcached.MemcachedClient; public class TestMemcached {
public static void main(String[] args) throws IOException {
MemcachedClient cache = new MemcachedClient(new InetSocketAddress("127.0.0.1", 11211));
System.out.println("Connect success");
for (int i = 1; i < 10; i++) {
cache.set("guowuxin" + i, 3600, new User(i + "","guowuxin","guowuxin"));
}
System.out.println("insert success");
User myObject = (User) cache.get("guowuxin1");
System.out.println("Get object from mem :" + myObject);
}
}
package com.guowuxin.memcached; import java.io.Serializable; public class User implements Serializable{ private static final long serialVersionUID = -372274003834027815L; private String userId; private String username; private String password; public User(final String userId,final String username,final String password) {
super();
this.userId = userId;
this.username = username;
this.password = password;
} public String getUserId() {
return userId;
} public void setUserId(String userId) {
this.userId = userId;
} public String getUsername() {
return username;
} public void setUsername(String username) {
this.username = username;
} public String getPassword() {
return password;
} public void setPassword(String password) {
this.password = password;
} @Override
public String toString() {
StringBuffer sb=new StringBuffer();
sb.append("userId="+this.userId);
sb.append("&username="+this.username);
sb.append("&password="+this.password);
return sb.toString();
}
}
2016-02-25 15:26:17.110 INFO net.spy.memcached.MemcachedConnection: Added {QA sa=/127.0.0.1:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
Connect success
2016-02-25 15:26:17.113 INFO net.spy.memcached.MemcachedConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@fa9cf
insert success
Get object from mem :userId=1&username=guowuxin&password=guowuxin
Memcached(一)在Windows上安装和测试memcached的更多相关文章
- NodeJs在windows上安装配置测试
Node.js简介简单的说 Node.js 就是运行在服务端的 JavaScript.Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境.Node.js 使用了一个 ...
- Python在Windows上安装配置测试
Python是跨平台的,它可以运行在Windows.Mac和各种Linux/Unix系统上.在Windows上写Python程序,放到Linux上也是能够运行的. 2.x还是3.x 目前,Python ...
- 在Windows上安装Elasticsearch 5.0
在windows上安装Elasticsearch Elasticsearch可以使用.zip软件包安装在Windows上. elasticsearch-service.bat命令,它将设置Elasti ...
- windows上安装apache python mod_python
综述: windows上安装apache python mod_python的例子.教程甚至图解都不少:但作为新手还是会出错,而且一时无法快速排解. 在此笔者将根据自己的实践经验,给出几个需要注意 ...
- Redis简介以及如何在Windows上安装Redis
Redis简介 Redis是一个速度非常快的非关系型内存数据库. Redis提供了Java,C/C++,C#,PHP,JavaScript,Perl,Object-C,Python,Ruby,Erla ...
- PHP 1:在Windows上安装和配置PHP,Apache和My SQL
原文:PHP 1:在Windows上安装和配置PHP,Apache和My SQL 如果你Google一把类似的主题,你会发现相关的文章可以塞满你的硬盘.在这里之所以把它再次拿出来,目的是想记录我作为一 ...
- 在Windows上安装Nexus 3.2.0-01
在Windows上安装Nexus 环境: Windows 7 apache-maven-3.3.9 JDK 1.8 下载Nexus: https://sonatype-download.globa ...
- Git学习系列之Windows上安装Git之后的一些配置(图文详解)
不多说,直接上干货! 前面博客 Git学习系列之Windows上安装Git详细步骤(图文详解) 第一次使用Git时,需要对Git进行一些配置,以方便使用Git. 不过,这种配置工作只需要进行一次便可, ...
- 在Windows上安装Elasticsearch 5.x
在Windows上安装Elasticsearch 5.x 自己想学习Elasticsearch,但是又不懂Linux,按照同事给的Linux安装教程,也是搞不明白,于是想先在Windows上安装一下入 ...
随机推荐
- 赵雅智:js知识点汇总
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvemhhb3lhemhpMjEyOQ==/font/5a6L5L2T/fontsize/400/fill/I0 ...
- qt QSqlQuery
QT数据库QSqlQuery SQL执行操作 QSqlQuery提供了对数据库记录的Select.Insert.Update.Delete操作. SELECT操作: QSqlQuery query ...
- kickstart安装
1.生成ks.cfg 文件 安装Kickstart # yum install system-config-kickstart 8.2 在桌面环境下配置Kickstart 启动X Windows 环境 ...
- AWS 命令行界面 + Python 的 AWS 开发工具包 (Boto3)
安装AWS CLI $ pip install awscli 安装Boto3 $ pip install boto3 设置AWS CLI $ aws configure AWS Access Key ...
- CentOS 6.6 yum源完全配置
原文地址 http://blog.csdn.net/halazi100/article/details/41311837 一 yum 简介 yum,是"Yellow dog Updater, ...
- Python教程:ORM连接Sqlite数据库,软件架构基础
python语言因其语法简单易学习,且高效率应用广,近几年来发展迅猛,一度进入编程语言排行榜前六名.为了使程序员能更快的学习Python语言,所以写的此教程.也可以说是对自己学习的总结.但文章尽量会使 ...
- 使用canvas制作在线画板
canvas绘图的强大功能,让人前仆后继的去研究它.代码全部加起来不足百行.还用到了h5中的<input type="color"/>和<input type=& ...
- i++与++i的区别
i++与++i的意思都是i自身加1,不过这个两个语句却有很大的区别. ++i,就是直接在i上再加1,这个无需多解释. i++会稍微特殊些,他会在下次执行语句,再遇到i时,才会在i身上加1. 打个比方, ...
- String类概述
(1)多个字符组成的一串数据. 其实它可以和字符数组进行相互转换. (2)构造方法: A:public String() B:public String ...
- 安卓获取Assets目录下的资源
获取Assets目录下的资源 *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 ! ...