1,启动 memcached 1.4.4-14
参照: http://blog.csdn.net/zhaotengfei36520/article/details/41315329
下载memcached的windows 32位版本程序,http://pan.baidu.com/s/1jIn1cO2解压缩一个目录中,比如d:/memcached
找到exe执行,memcached.exe -d install,就会在window的服务里面进行管理了,设为自动启动。
修改参数,windows下需要通过修改注册表信息进行设置,打开注册表,找 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\memcached 在其中有一个“ImagePath”项,值为: "D:\memcached\memcached.exe" -d runservice 在后面加上“-m 1024 -c 2048 -p 11210”。等即可。重启服务后生效
2,php 5.4.8.0与apache2.2集成
参照:http://blog.csdn.net/mlz_2/article/details/62430031
两个apache都安装到windows服务里,第二个这样执行命令:
httpd.exe -k install -n Apache2.2_PHP
3,memAdimin监控管理memcached
参照:http://www.cnblogs.com/huangxincheng/p/5471211.html
下载MemAdmin,http://www.junopen.com/memadmin/ ,memadmin-1.0.12.tar.gz,解压缩之后一个menadmin的文件夹,将它放到php发布的路径下面
下载memcache.dll,http://pan.baidu.com/s/1qY0gdFu ,使用的【php_memcache.dll(php5.4.7)】里面的dll文件。
将memcache.dll放到php/ext下面
在php.ini中增加extension=memcache.dll
php.exe -m 查看memcache.dll是否已加载成功
4,mybatis集成memcached
参考:http://www.mybatis.org/memcached-cache/
在maven的pom中增加 <dependency>
<groupId>org.mybatis.caches</groupId>
<artifactId>mybatis-memcached</artifactId>
<version>1.0.0</version>
</dependency>
memcached的配置文件时memcached.properties,默认的配置如下
Property | Default | Description |
---|---|---|
org.mybatis.caches.memcached.keyprefix | _mybatis_ | any string identifier |
org.mybatis.caches.memcached.servers | localhost:11211 | space separated list of ${host}:${port} |
org.mybatis.caches.memcached.connectionfactory | net.spy.memcached.DefaultConnectionFactory | Any class that implementsnet.spy.memcached.ConnectionFactory |
org.mybatis.caches.memcached.expiration | the number of seconds in 30 days | the expiration time (in seconds) |
org.mybatis.caches.memcached.asyncget | false | flag to enable/disable the async get |
org.mybatis.caches.memcached.timeout | 5 | the timeout when using async get |
org.mybatis.caches.memcached.timeoutunit | java.util.concurrent.TimeUnit.SECONDS | the timeout unit when using async get |
org.mybatis.caches.memcached.compression | false | if true, objects will be GZIP compressed before putting them to Memcached |
<mapper namespace="org.acme.FooMapper">
<cache type="org.mybatis.caches.memcached.MemcachedCache" />
<select ... userCache=false>
</select>
</mapper>
二级缓存会在这个mapper中的insert/update/delete之后,清空相关的缓存