Mac OS 下搭建memcached java 增删改查

    安装

1,安装brew:访问官网 http://brew.sh/

     直接拷贝

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 

到命令行,回车,按提示完成安装。


2,用brew安装memcached

   brew install memcached

回车,按提示完成安装,一分钟之内。


3,启动memcached

  

sudo /usr/local/bin/memcached -d -m 2048  -u root -l 127.0.0.1 -p 11211 -c 1024 -P /tmp/memcached.pid

参数说明:
-d 启动为守护进程
-m 分配给 Memcached使用的内存数量,单位是MB,默认为64MB
-u 运行 Memcached的用户,仅当作为root运行时
-l 监听的服务器IP地址,默认为环境变量INDRR_ANY的值
-p 设置 Memcached监听的端口,最好是1024以上的端口
-c 设置最大并发连接数,默认为1024
-P 设置保存 Memcached的pid文件,与-d选择同时使用

参考:http://blog.163.com/evan__zhang@yeah/blog/static/121032757201031205628800/

 使用 memcached 增删改查、cas等

     1,使用java

      2,memcached客户端使用 Xmemcached,

其他java memcached客户端比较参考:http://blog.csdn.net/arui_email/article/details/8129400


       刚放实例代码:https://github.com/killme2008/xmemcached



  Memcached stats查看状态

终端输入:

localhost:~ gzq$ telnet 127.0.0.1 11211

回车

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.


接着直接输入:stats

输出


STAT pid 55020
STAT uptime 90432
STAT time 1468574529
STAT version 1.4.24
STAT libevent 2.0.22-stable
STAT pointer_size 64
STAT rusage_user 16.360309
STAT rusage_system 37.418904
STAT curr_connections 5
STAT total_connections 203
STAT connection_structures 10
STAT reserved_fds 20
STAT cmd_get 1255439
STAT cmd_set 1215415
STAT cmd_flush 0
STAT cmd_touch 0
STAT get_hits 1255434
STAT get_misses 5
STAT delete_misses 0
STAT delete_hits 8
STAT incr_misses 0
STAT incr_hits 5
STAT decr_misses 0
STAT decr_hits 79
STAT cas_misses 0
STAT cas_hits 730054
STAT cas_badval 485336
STAT touch_hits 0
STAT touch_misses 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 52580358
STAT bytes_written 53257310
STAT limit_maxbytes 2147483648
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT hash_power_level 16
STAT hash_bytes 524288
STAT hash_is_expanding 0
STAT malloc_fails 0
STAT bytes 903
STAT curr_items 3
STAT total_items 730077
STAT expired_unfetched 1
STAT evicted_unfetched 0
STAT evictions 0
STAT reclaimed 1
STAT crawler_reclaimed 0
STAT crawler_items_checked 0
STAT lrutail_reflocked 63909
END


每个参数的具体含义,可以参考:http://blog.chinaunix.net/uid-24250828-id-3242949.html





你可能感兴趣的:(J2EE)