- 论坛徽章:
- 0
|
本帖最后由 ri0day 于 2011-12-30 17:01 编辑
昨天下午有空。写了这么个东西。可以支持正则表达式的批量清除key。有需要的自己拿去用吧。源码简单。一看就知道怎么用了。
源码地址:
https://gist.github.com/1538831
使用方法:
1.查看状态:
[root@host5-7 ~]# ./memcache_cli.sh -h 192.168.5.21 -p 19867 -c stats
STAT pid 15674
STAT uptime 270229
STAT time 1325235430
STAT version 1.2.8
STAT pointer_size 64
STAT rusage_user 13.848865
STAT rusage_system 40.030501
STAT curr_items 276188
STAT total_items 504205
STAT bytes 39551126
STAT curr_connections 11
STAT total_connections 57243
STAT connection_structures 33
STAT cmd_flush 1
STAT cmd_get 558689
STAT cmd_set 503356
STAT get_hits 346932
STAT get_misses 211757
STAT evictions 0
STAT bytes_read 156384474
STAT bytes_written 18041867888
STAT limit_maxbytes 2147483648
STAT threads 2
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT replication MASTER
STAT repcached_version 2.2
STAT repcached_qi_free 8185
2.查看key与之相对应的vaule
[root@host5-7 ~]# ./memcache_cli.sh -h 192.168.5.21 -p 19867 -c get -k wumin1
VALUE wumin1 0 3
123
3.删除指定key的
[root@host5-7 ~]# ./memcache_cli.sh -h 192.168.5.21 -p 19867 -c purge -k wumin1
DELETED
4.批量删除key
先set 几个
[root@host5-7 ~]# telnet 192.168.5.21 19867
Trying 192.168.5.21...
Connected to 192.168.5.21 (192.168.5.21).
Escape character is '^]'.
set test1 0 0 3
123
STORED
set test2 0 0 3
345
STORED
set test3 0 0 3
567
STORED
set test4 0 0 3
789
STORED
quit
Connection closed by foreign host.
批量删除,
[root@host5-7 ~]# ./memcache_cli.sh -h 192.168.5.21 -p 19867 -c superpurge -k test
DELETED
DELETED
DELETED
DELETED |
|