memcached 学习目录:
memcached 学习 1—— memcached+spring配置
这几天自己搭建项目环境,解决问题如下: 有关常见的配置这里没有列出,中间遇到的搭建问题比较顺利google出来的也没有写 1.列出本机的 globalApplication.xml 配置文件有关memcached的部分:
<!-- ==================================== Memcached缓存客服端 ========================================= --> <bean id ="memcachedPool" class= "com.danga.MemCached.SockIOPool" factory-method= "getInstance" init-method ="initialize" destroy-method="shutDown" > <constructor-arg > <value >neeaMemcachedPool </value > </constructor-arg > <property name ="servers"> <list > <value >220.181.188.246:12000 </value ><!-- 测试缓存服务器 --> <!--多服务器 --> </list > </property > <!-- <property name="weights"> --> <!-- <list> --> <!-- </list> --> <!-- </property> --> <property name ="initConn"> <value >40 </value > </property > <property name ="minConn"> <value >40 </value > </property > <property name ="maxConn"> <value >200 </value > </property > <property name ="maintSleep"> <value >5000 </value > </property > <property name ="nagle"> <value >false </value > </property > <property name ="socketTO"> <value >3000 </value > </property > </bean > <bean id ="memcachedClient" class= "com.danga.MemCached.MemCachedClient" > <constructor-arg > <value >neeaMemcachedPool </value > </constructor-arg > <!-- <property name="compressEnable"> <value>true</value> </property> <property name="compressThreshold"> <value>4096</value> </property> --> </bean > <!-- ====================================缓存客服端 ========================================= -->
2. 导入 java_memcached-release_2.6.6 后一直报错memcachedPool,相关的错误,发现还缺少jar包,
又导入另外几个依赖的包:commons-pool-1.5.6,slf4j-api-1.6.1,slf4j-simple-1.6.1 以上的官方下载地址:
https://github.com/gwhalin/Memcached-Java-Client/downloads 3.由于没找到 java_memcached-release_2.6.6 的源码 这里下了另外一个memcachedClient,源码也有,下载地址:
http://grepcode.com/snapshot/repo1.maven.org/maven2/com.whalin/Memcached-Java-Client/3.0.1 配置如下:
<!-- ====================================Memcacheed缓存客服端 ========================================= --> <bean id="memcachedPool" class="com.whalin.MemCached.SockIOPool" factory-method="getInstance" init-method="initialize" destroy-method="shutDown"> <constructor-arg> <value>memCachedPool</value> </constructor-arg> <property name="servers"> <list> <value>220.181.188.246:12000</value><!-- 测试缓存服务器 --> <!-- <value>172.100.1.241:12000</value>正式缓存服务器 --> <!--多服务器 --> </list> </property> <!-- <property name="weights"> --> <!-- <list> --> <!-- <value>5</value> --> <!-- <value>5</value> --> <!-- <value>5</value> --> <!-- <value>5</value> --> <!-- </list> --> <!-- </property> --> <property name="initConn"> <value>40</value> </property> <property name="minConn"> <value>40</value> </property> <property name="maxConn"> <value>200</value> </property> <property name="maintSleep"> <value>5000</value> </property> <property name="nagle"> <value>false</value> </property> <property name="socketTO"> <value>3000</value> </property> </bean> <bean id="memcachedClient" class="com.whalin.MemCached.MemCachedClient"> <constructor-arg> <value>memCachedPool</value> </constructor-arg> <!-- <property name="compressEnable"> <value>true</value> </property> <property name="compressThreshold"> <value>4096</value> </property> --> </bean> <!-- ====================================缓存客服端 ========================================= -->