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上安装一下入 ...
随机推荐
- shell 两个rpm包做差分
当前目录下两个rpm包做差分. *.rpm 两个目录,解压rpm包. export LANG=c 差分判断是脚本还是Binary Files 脚本添加命令行提示符,awk. [root@sj_x8 ...
- Bash String Manipulation Examples – Length, Substring, Find and Replace--reference
In bash shell, when you use a dollar sign followed by a variable name, shell expands the variable wi ...
- Java synchronized 总结
在Java开发的时候经常会用到关键字synchronized来对代码进行同步,在使用的过程中,对于synchronized确不是很熟悉,最近在看Spring源码时,发现有不少地方都用到同步,因此,趁此 ...
- 加速Android Studio/Gradle构建
已经使用Android Studio进行开发超过一年,随着项目的增大,依赖库的增多,构建速度越来越慢,现在最慢要6分钟才能build一个release的安装包,在网上查找资料,发现可以通过一些配置可以 ...
- 如何在mysql命令窗口获取到程序正在执行的sql语句
步骤: 1.进入mysql的命令窗口: 2.运行use information_schema; 3.运行select * from PROCESSLIST where info is not null ...
- PHPinstanceof filal这几个关键字的使用
instanceof表示属不属于的意思 eg: class person{} class Student extends person{} $s=new person(); $st=new stude ...
- JS火狐与IE的差别
function isIE(){ //ie? ) return true; else return false; } if(!isIE()){ //firefox innerText define H ...
- jedis访问redis学习笔记
最近在学习redis,在网上查了些文章,利用他人已有的知识,总结写下了这篇文章,大部分内容还是引用别人的文章内容.经过测试发现spring-data-redis现在有的版本只能支持reids 2.6和 ...
- (转)OpenVPN下载、安装、配置及使用详解
原文地址:http://www.365mini.com/page/14.htm OpenVPN简介 OpenVPN是一个用于创建虚拟专用网络(Virtual Private Network)加密通道的 ...
- 高级Magento模型 EAV
我们讲过Magento有两种模型,简单模型和EAV(Entity Attribute Value)模型.上一章我们讲过所有的Magento模型都是继承自Mage_Core_Model_Abstract ...