配置APDPlat使用Memcache

技术文档网 2021-05-06

1、安装memcached

apt-get install memcached

2、memcached的基本设置:

-p 监听的端口
-l 连接的IP地址, 默认是本机
-d start 启动memcached服务
-d restart 重起memcached服务
-d stop|shutdown 关闭正在运行的memcached服务
-d install 安装memcached服务
-d uninstall 卸载memcached服务
-u 以的身份运行 (仅在以root运行的时候有效)
-m 最大内存使用,单位MB。默认64MB
-M 内存耗尽时返回错误,而不是删除项
-c 最大同时连接数,默认是1024
-f 块大小增长因子,默认是1.25
-n 最小分配空间,key+value+flags默认是48
-h 显示帮助

3、启动memcached,如果memcached和tomcat不在一台机器上,则-l选项后面加入运行memcached的主机的主机名或是IP地址

memcached -d -m 6000 -p 11211 -u root -l localhost

memcached -d -m 6000 -p 11211 -u root -l host8

memcached -d -m 6000 -p 11211 -u root -l 192.168.1.8

4、停止memcached

memcached -d stop -u root

5、查询memcached状态

telnet localhost 11211

telnet host8 11211

telnet 192.168.1.8 11211

输入命令:stats

6、打开APDPlat_Web -> 其他源 -> src/main/resources -> db.local.properties,在这个文件里面增加:

hibernate.cache.provider_class=com.googlecode.hibernate.memcached.MemcachedCacheProvider
hibernate.memcached.servers=host8:11211  或   hibernate.memcached.servers=localhost:11211

相关文章

  1. memcached内存管理机制

    memcached默认采用的是Slab Allocator的机制分配管理内存的,在此之前,内存的分配是通过对所有的记录简单地进行malloc和free来进行的,但这种方式容易造成很多内存碎片,加重操作

  2. 配置APDPlat使用Memcache

    1、安装memcached apt-get install memcached 2、memcached的基本设置: -p 监听的端口 -l 连接的IP地址, 默认是本机 -d start 启动mem

随机推荐

  1. memcached内存管理机制

    memcached默认采用的是Slab Allocator的机制分配管理内存的,在此之前,内存的分配是通过对所有的记录简单地进行malloc和free来进行的,但这种方式容易造成很多内存碎片,加重操作

  2. 配置APDPlat使用Memcache

    1、安装memcached apt-get install memcached 2、memcached的基本设置: -p 监听的端口 -l 连接的IP地址, 默认是本机 -d start 启动mem