http://www.runoob.com/memcached/memcached-cas.html
https://github.com/memcached/memcached/blob/master/doc/protocol.txt 很重要,解释了所有相关含义
==============================
[root@cn-21 ~]# ps -ef|grep mem
systemd+ 3338 3319 0 2017 ? 01:13:09 memcached
root 29927 29897 0 15:34 pts/1 00:00:00 grep –color=auto mem
[root@cn-21 ~]# rpm -qa|grep mem
memcached-1.4.15-10.el7_3.1.x86_64
[root@cn-21 ~]# rpm -ql memcached
/etc/sysconfig/memcached
/usr/bin/memcached
/usr/bin/memcached-tool
/usr/lib/systemd/system/memcached.service
/usr/share/doc/memcached-1.4.15
/usr/share/doc/memcached-1.4.15/AUTHORS
/usr/share/doc/memcached-1.4.15/CONTRIBUTORS
/usr/share/doc/memcached-1.4.15/COPYING
/usr/share/doc/memcached-1.4.15/ChangeLog
/usr/share/doc/memcached-1.4.15/NEWS
/usr/share/doc/memcached-1.4.15/README.md
/usr/share/doc/memcached-1.4.15/protocol.txt
/usr/share/doc/memcached-1.4.15/readme.txt
/usr/share/doc/memcached-1.4.15/threads.txt
/usr/share/man/man1/memcached-tool.1.gz
/usr/share/man/man1/memcached.1.gz
[root@cn-21 ~]# cat /etc/sysconfig/memcached
PORT=”11211″
USER=”memcached”
MAXCONN=”1024″
CACHESIZE=”64″
OPTIONS=””
==============================
Memcached本身是使用C开发的,客户端可以是php、C#、或者java。
==============================
命令汇总
stats items
stats sizes
set runoob 0 900 9
get runoob
flush_all
===============================
[root@cn-21 ~]# telnet localhost 11211
Trying ::1…
Connected to localhost.
Escape character is ‘^]’.
stats items
END
stats slabs
STAT 7:chunk_size 384
STAT 7:chunks_per_page 2730
STAT 7:total_pages 1
STAT 7:total_chunks 2730
STAT 7:used_chunks 0
STAT 7:free_chunks 2730
STAT 7:free_chunks_end 0
STAT 7:mem_requested 0
STAT 7:get_hits 72
STAT 7:cmd_set 49
STAT 7:delete_hits 18
STAT 7:incr_hits 0
STAT 7:decr_hits 0
STAT 7:cas_hits 0
STAT 7:cas_badval 0
STAT 7:touch_hits 0
STAT 9:chunk_size 600
STAT 9:chunks_per_page 1747
STAT 9:total_pages 1
STAT 9:total_chunks 1747
STAT 9:used_chunks 0
STAT 9:free_chunks 1747
STAT 9:free_chunks_end 0
STAT 9:mem_requested 0
STAT 9:get_hits 4
STAT 9:cmd_set 2
STAT 9:delete_hits 0
STAT 9:incr_hits 0
STAT 9:decr_hits 0
STAT 9:cas_hits 0
STAT 9:cas_badval 0
STAT 9:touch_hits 0
STAT 10:chunk_size 752
STAT 10:chunks_per_page 1394
STAT 10:total_pages 1
STAT 10:total_chunks 1394
STAT 10:used_chunks 0
STAT 10:free_chunks 1394
STAT 10:free_chunks_end 0
STAT 10:mem_requested 0
STAT 10:get_hits 82
STAT 10:cmd_set 44
STAT 10:delete_hits 0
STAT 10:incr_hits 0
STAT 10:decr_hits 0
STAT 10:cas_hits 0
STAT 10:cas_badval 0
STAT 10:touch_hits 0
STAT 11:chunk_size 944
STAT 11:chunks_per_page 1110
STAT 11:total_pages 1
STAT 11:total_chunks 1110
STAT 11:used_chunks 0
STAT 11:free_chunks 1110
STAT 11:free_chunks_end 0
STAT 11:mem_requested 0
STAT 11:get_hits 8
STAT 11:cmd_set 2
STAT 11:delete_hits 0
STAT 11:incr_hits 0
STAT 11:decr_hits 0
STAT 11:cas_hits 0
STAT 11:cas_badval 0
STAT 11:touch_hits 0
STAT active_slabs 4
STAT total_malloced 4194304
END
=====================
stats settings
STAT maxbytes 67108864
STAT maxconns 1024
STAT tcpport 11211
STAT udpport 11211
STAT inter NULL
STAT verbosity 0
STAT oldest 0
STAT evictions on
STAT domain_socket NULL
STAT umask 700
STAT growth_factor 1.25
STAT chunk_size 48
STAT num_threads 4
STAT num_threads_per_udp 4
STAT stat_key_prefix :
STAT detail_enabled no
STAT reqs_per_event 20
STAT cas_enabled yes
STAT tcp_backlog 1024
STAT binding_protocol auto-negotiate
STAT auth_enabled_sasl no
STAT item_size_max 1048576
END
=====================
stats sizes
STAT sizes_status disabled
set runoob 0 900 9
memcached
STORED
get runoob
VALUE runoob 0 9
memcached
END
flush_all
OK
get runoob
END
======================
<command name> <key> <flags> <exptime> <bytes> [noreply]\r\n
cas <key> <flags> <exptime> <bytes> <cas unique> [noreply]\r\n
按秒算,5是数据库的长度,即5字节,多于5和小于5都会报错
set file 0 300 5
iiiiii
CLIENT_ERROR bad data chunk
ERROR
set file 0 300 5
iiii
CLIENT_ERROR bad data chunk
ERROR
set file 0 300 5
iiiii
STORED
======================
[root@cn-21 ~]# memcached-tool localhost:11211 stats
#localhost:11211 Field Value
accepting_conns 1
auth_cmds 0
auth_errors 0
bytes 0
bytes_read 139360283
bytes_written 232272906
cas_badval 0
cas_hits 0
cas_misses 0
cmd_flush 147
cmd_get 298
cmd_set 99
cmd_touch 0
conn_yields 0
connection_structures 52
crawler_items_checked 1
crawler_reclaimed 0
curr_connections 38
curr_items 0
decr_hits 0
decr_misses 0
delete_hits 18
delete_misses 0
direct_reclaims 0
evicted_active 0
evicted_unfetched 0
evictions 0
expired_unfetched 34
get_expired 0
get_flushed 0
get_hits 168
get_misses 130
hash_bytes 524288
hash_is_expanding 0
hash_power_level 16
incr_hits 0
incr_misses 0
libevent 2.0.21-stable
limit_maxbytes 67108864
listen_disabled_num 0
log_watcher_sent 0
log_watcher_skipped 0
log_worker_dropped 0
log_worker_written 0
lru_bumps_dropped 0
lru_crawler_running 0
lru_crawler_starts 203490
lru_maintainer_juggles 12327347
lrutail_reflocked 22
malloc_fails 0
max_connections 1024
moves_to_cold 112
moves_to_warm 27
moves_within_lru 0
pid 1
pointer_size 64
reclaimed 41
rejected_connections 0
reserved_fds 20
rusage_system 3602.709727
rusage_user 795.646915
slab_global_page_pool 0
slab_reassign_busy_deletes 0
slab_reassign_busy_items 0
slab_reassign_chunk_rescues 0
slab_reassign_evictions_nomem 0
slab_reassign_inline_reclaim 0
slab_reassign_rescues 0
slab_reassign_running 0
slabs_moved 0
threads 4
time 1515488925
time_in_listen_disabled_us 0
total_connections 177
total_items 98
touch_hits 0
touch_misses 0
uptime 2770390
version 1.5.3