第一步:在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 >
            <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>

相关文章:

  • 2021-11-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-24
  • 2022-12-23
  • 2022-12-23
  • 2022-01-10
猜你喜欢
  • 2022-01-17
  • 2021-12-22
  • 2021-10-13
  • 2022-12-23
  • 2021-10-14
  • 2022-12-23
相关资源
相似解决方案