第一步:在linux机或windows机上安装memcached服务端(server)

linux中安装memcached:centos中命令 yum -y install memcached

如果没有联网下载mencached的安装包(注意:需要安装依赖libevent)

从网上下载安装包,解压后make&&make install就完成了

第二步:项目中导入memcached客户端jar(client)有两个版本,选择2.4的

第三步:spring集成memcached(memcached.xml中)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
     http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

<!-- Memcached 配置 -->
    <bean id="memCachedClient" class="com.danga.MemCached.MemCachedClient">
        <constructor-arg>
            <value>sockIOPool</value>
        </constructor-arg>
    </bean>
    <!-- Memcached连接池 -->
    <bean id="sockIOPool" class="com.danga.MemCached.SockIOPool" factory-method="getInstance" init-method="initialize" destroy-method="shutDown">
        <constructor-arg>
            <value>sockIOPool</value>
        </constructor-arg>
        <property name="servers">
            <list>

<!--memcached集群,有几个就列几个11211为端口号-->

<value>192.168.200.149:11211</value>

<value>192.168.200.150:11211</value>

</list>
        </property>
        <property name="weights">
            <list>
                <value>1</value>
            </list>
        </property>
    </bean>
</beans>

最新文章

  1. BroadcastReceiver几种常见监听
  2. C# LINQ详解(转)
  3. 设置IE默认文本模式的方法
  4. 关于IE中通过http-equiv=&quot;X-UA-Compatible指定文件兼容性模式
  5. 使用supervisor提高nodejs调试效率 (已验证)
  6. SQL Server文本和图像函数
  7. java 转义字符
  8. http: URL、请求方式
  9. YouTube CEO关于工作和生活平衡的完美回答
  10. C#常用的数据格式转换
  11. iOS TextField输入框点击键盘时随着键盘上移
  12. Fruit Feast
  13. Java 9 尝鲜之JShell交互式编程环境
  14. 【转载】stm32中断学习
  15. YYHS-Super Big Stupid Cross(二分+扫描线+平衡树)
  16. Java 基础 IO流之序列化
  17. Beta阶段冲刺汇总(团队)
  18. Python3 引入sqlite3时出现错误:ModuleNotFoundError: No module named &#39;_sqlite3&#39;
  19. virtualbox+vagrant学习-2(command cli)-6-vagrant init命令
  20. CentOS 添加新硬件硬盘,扩展空间而无需重启虚拟机

热门文章

  1. php调试函数
  2. java中成员变量、代码块、构造函数运行顺序
  3. Atitit.软件GUI按钮与仪表盘(01)--js区-----js格式化的使用
  4. atitit.XML类库选型及object 对象bean 跟json转换方案
  5. [svc]linux查看主板型号及内存硬件信息
  6. SimpleDateFormat线程不安全及解决的方法
  7. java中==和equals和hashcode的区别详解
  8. Struts2源码阅读(一)_Struts2框架流程概述
  9. tornado部署
  10. nyoj 952 最大四边形 计算几何 转载