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上安装一下入 ...
随机推荐
- android89 服务service
#服务 服务不能new,new出来的只是一个普通java对象不是服务,只能够通过Intent和startService(intent)创建服务. ###开启方式 * startService,onCr ...
- Eclipse启动时报需要安装"Java SE 6 Runtime"致无法启动解决方案
今天心血来潮,把MBP升级到了osx mavericks,然后启动了闲置好久的eclipse,启动时居然报错了: 若要打开Eclipse.app,您需要Java SE 6 runtime,您想现在安装 ...
- 关于ellipsize属性使用的一些细节
ellipsize主要是处理当文字长度超过TextView可显示的长度的时候,系统的处理方式,ellipsize主要有以下几种值: android:ellipsize="start" ...
- 在文件地理数据库中使用 SQL 进行报告和分析 (转)
================以下摘自ArcGIS10.1帮助=================== 文件地理数据库允许在 QueryDef 中通过 SubFields(字段列表)方法使用表达式和别 ...
- 深入理解C#中this/partial/null的使用
一.this关键字作用 1.this表示当前运行中的对象 Eg: public class Person { public int age; public string name; public Pe ...
- 页面嵌套 Iframe 产生缓存导致页面数据不刷新问题
最近遇到个比较古怪的问题:当页面嵌套多个 Iframe 时会出现 Iframe 里包含的页面无法看到最新的页面信息. 初步解决方案,在 Iframe 指向的页面地址后缀添加一个随机数或者时间戳.这样能 ...
- 使用solr搭建你的全文检索
Solr 是一个可供企业使用的.基于 Lucene 的开箱即用的搜索服务器.对Lucene不熟?那么建议先看看下面两篇文档: 实战Lucene,第 1 部分: 初识 Lucene:http://www ...
- spring线程池配置
源自:http://zjriso.iteye.com/blog/771706 1.了解 TaskExecutor接口 Spring的TaskExecutor接口等同于java.util.concurr ...
- OC中的字符串常用方法
OC中的字符串常用方法 OC中对字符串进行操作使用了Foundation框架中的NSString类(不可变).NSMutableString类(可变). NSString 1.创建字符串 [objc] ...
- HTML5游戏开发框架phaser学习日志(一)下载phaser,在IIS中配置phaser的examples站点
phaser是HTML5开源的游戏引擎. 一.源码下载地址:https://github.com/photonstorm/phaser 二.文档结构: 三.将phaser-master部署到IIS中站 ...