Windows下安装Memcache
2016-12-17 16:11
399 查看
由于官网没有Window版本的memcache,需要在网上搜索下载:
可以参考:32位系统 1.4.4版本:http://static.runoob.com/download/memcached-win32-1.4.4-14.zip
64位系统 1.4.4版本:http://static.runoob.com/download/memcached-win64-1.4.4-14.zip
memcached <1.4.5 版本安装
1、解压下载的安装包到指定目录。2、在 1.4.5 版本以前 memcached 可以作为一个服务安装,使用管理员权限运行以下命令:
c:\memcached\memcached.exe -d install
注意:你需要使用真实的路径替代 c:\memcached\memcached.exe。
3、然后我们可以使用以下命令来启动和关闭 memcached 服务:
c:\memcached\memcached.exe -d start c:\memcached\memcached.exe -d stop
4、如果要修改 memcached 的配置项, 可以在命令行中执行 regedit.exe 命令打开注册表并找到 "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\memcached" 来进行修改。
如果要提供 memcached 使用的缓存配置 可以修改 ImagePath 为:
"c:\memcached\memcached.exe" -d runservice -m 512
-m 512 意思是设置 memcached 最大的缓存配置为512M。
此外我们还可以通过使用 "c:\memcached\memcached.exe -h" 命令查看更多的参数配置。
5、如果我们需要卸载 memcached ,可以使用以下命令:
c:\memcached\memcached.exe -d uninstall
memcached >= 1.4.5 版本安装
1、解压下载的安装包到指定目录。2、在 memcached1.4.5 版本之后,memcached 不能作为服务来运行,需要使用任务计划中来开启一个普通的进程,在 window 启动时设置 memcached自动执行。
我们使用管理员身份执行以下命令将 memcached 添加来任务计划表中:
schtasks /create /sc onstart /tn memcached /tr "'c:\memcached\memcached.exe' -m 512"
注意:你需要使用真实的路径替代 c:\memcached\memcached.exe。
注意:-m 512 意思是设置 memcached 最大的缓存配置为512M。
注意:我们可以通过使用 "c:\memcached\memcached.exe -h" 命令查看更多的参数配置。
3、如果需要删除 memcached 的任务计划可以执行以下命令:
schtasks /delete /tn memcached
SpringMVC中Maven配置Memcached
第一步:引入jar;在pom文件中添加以下内容<!-- memcache --> <dependency> <groupId>com.whalin</groupId> <artifactId>Memcached-Java-Client</artifactId> <version>3.0.0</version> </dependency>
第二步:配置Memcache相关属性(init.properties)
#######################设置Memcached服务器参数####################### #设置服务器地址 memcached.server=目标服务器ip:11211 #该端口号默认为11211 #容错 memcached.failOver=true #设置初始连接数 memcached.initConn=20 #设置最小连接数 memcached.minConn=10 #设置最大连接数 memcached.maxConn=250 #设置连接池维护线程的睡眠时间 memcached.maintSleep=3000 #设置是否使用Nagle算法(Socket的参数),如果是true在写数据时不缓冲,立即发送出去 memcached.nagle=false #设置socket的读取等待超时时间 memcached.socketTO=3000 #设置连接心跳监测开关 memcached.aliveCheck=true #######################设置Memcached服务器参数#######################
第三步:加载Memcache属性(memcached-content.xml)
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd"> <!-- Memcached配置 --> <bean id="memcachedPool" class="com.whalin.MemCached.SockIOPool" factory-method="getInstance" init-method="initialize" destroy-method="shutDown"> <property name="servers"> <list> <value>${memcached.server}</value> </list> </property> <property name="initConn"> <value>${memcached.initConn}</value> </property> <property name="minConn"> <value>${memcached.minConn}</value> </property> <property name="maxConn"> <value>${memcached.maxConn}</value> </property> <property name="maintSleep"> <value>${memcached.maintSleep}</value> </property> <property name="nagle"> <value>${memcached.nagle}</value> </property> <property name="socketTO"> <value>${memcached.socketTO}</value> </property> </bean> </beans>
第四步:引入到spring配置文件中(applicationContext.xml)
<!-- 只需要加入这一句就可以 --> <import resource="memcached-content.xml"/>
ok,大功告成!至于Memcache应用, 可以网上搜以下,就是一个单纯的exe文件, 用的时候打开就行,如图, 打开后就是这个样子
要想看是否连接成功的话,可以在cmd中telnet 服务器地址 11211 (服务器地址与端口号之间是一个空格, 不要输入冒号)
相关文章推荐
- 在windows下安装memcache+amfphp
- Windows下Memcache的安装
- 【转】Windows下的Memcache安装
- Windows下的Memcache安装
- Windows下的Memcache安装
- Windows下的Memcache安装
- Windows下的Memcache安装
- PHP:Windows下 Memcache 的安装
- Windows 2003安装Memcache
- Windows下的Memcache安装
- windows下memcache的安装
- windows下安装memcache及使用
- Windows下的Memcache安装
- Windows下的Memcache安装
- Windows下的Memcache安装
- Windows下的Memcache安装
- Windows下的Memcache安装
- [原创]Windows下Memcache简介及安装手册
- Windows下Memcache的安装方法
- Windows下的Memcache安装