检查telnet程序是否可用:which telnet

如果没有安装,则安装之:aptitude install telnet

开始测试:

dev-server:~# telnet 192.168.0.240 11211
Trying 192.168.0.240…
Connected to 192.168.0.240.
Escape character is ‘^]’.
set key1 0 60 9
seaprince
STORED
get key1
VALUE key1 0 9
seaprince
END
stats
STAT pid 2557
STAT uptime 249422
STAT time 1246175982
STAT version 1.2.2
STAT pointer_size 32
STAT rusage_user 0.008000
STAT rusage_system 0.004000
STAT curr_items 2
STAT total_items 24
STAT bytes 121
STAT curr_connections 1
STAT total_connections 30
STAT connection_structures 2
STAT cmd_get 26
STAT cmd_set 24
STAT get_hits 21
STAT get_misses 5
STAT evictions 0
STAT bytes_read 3021
STAT bytes_written 2886
STAT limit_maxbytes 67108864
STAT threads 1
END
quit
Connection closed by foreign host.
dev-server:~#

整数操作:

dev-server:~# telnet 192.168.0.240 11211
Trying 192.168.0.240…
Connected to 192.168.0.240.
Escape character is ‘^]’.
get key1
END
set key1 0 3600 3 123
123
STORED
incr key1 5
128
decr key1 5
123
delete key1
DELETED
get key1
END
quit
Connection closed by foreign host.
dev-server:~#

高亮的是需要输入的命令。跟随的是返回。

参考:http://lists.danga.com/pipermail/memcached/2005-April/001332.html