telnet操作memcache
1.使用方法
1. 连接到memcached
telnet 192.168.1.100 11211
add name 0 60 5 [说明 add 是指令名 name 是key的名字 (是以key/value存放), 0 标志, 60 表示数据存放 60s 5表示 放入多大数据 ], 如果一个key已经存在,再放入是失败的.
get name [获取 name的值]
//更新
set name 0 60 5 [如果 name 这个key存在,就是更新, 如果key不存在,就是添加]
//删除
delete key值
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 显示帮助
memcached的基本命令(当memcached 启动后 用于对memcached管理的数据和本身运行状态相关的命令):
| Command | Description | Example | 
| get | Reads a value | get mykey | 
| set | Set a key unconditionally | set mykey 0 60 5 | 
| add | Add a new key | add newkey 0 60 5 | 
| replace | Overwrite existing key | replace key 0 60 5 | 
| append | Append data to existing key | append key 0 60 15 | 
| prepend | Prepend data to existing key | prepend key 0 60 15 | 
| incr | Increments numerical key value by given number | incr mykey 2 | 
| decr | Decrements numerical key value by given number | decr mykey 5 | 
| delete | Deletes an existing key | delete mykey | 
| flush_all | Invalidate specific items immediately | flush_all | 
| Invalidate all items in n seconds | flush_all 900 | |
| stats | Prints general statistics | stats | 
| Prints memory statistics | stats slabs | |
| Prints memory statistics | stats malloc | |
| Print higher level allocation statistics | stats items | |
| stats detail | ||
| stats sizes | ||
| Resets statistics | stats reset | |
| version | Prints server version. | version | 
| verbosity | Increases log level | verbosity | 
| quit | Terminate telnet session | quit | 
对查看的信息的关键字中英文对照表
| pid | memcache服务器的进程ID | 
| uptime | 服务器已经运行的秒数 | 
| time | 服务器当前的unix时间戳 | 
| version | memcache版本 | 
| pointer_size | 当前操作系统的指针大小(32位系统一般是32bit) | 
| rusage_user | 进程的累计用户时间 | 
| rusage_system | 进程的累计系统时间 | 
| curr_items | 服务器当前存储的items数量 | 
| total_items | 从服务器启动以后存储的items总数量 | 
| bytes | 当前服务器存储items占用的字节数 | 
| curr_connections | 当前打开着的连接数 | 
| total_connections | 从服务器启动以后曾经打开过的连接数 | 
| connection_structures | 服务器分配的连接构造数 | 
| cmd_get | get命令(获取)总请求次数 | 
| cmd_set | set命令(保存)总请求次数 | 
| get_hits | 总命中次数 | 
| get_misses | 总未命中次数 | 
| evictions | 为获取空闲内存而删除的items数(分配给memcache的空间用满后需要删除旧的items来得到空间分配给新的items) | 
| bytes_read | 总读取字节数(请求字节数) | 
| bytes_written | 总发送字节数(结果字节数) | 
| limit_maxbytes | 分配给memcache的内存大小(字节) | 
| threads | 当前线程数 | 
特别注意:
memcached –m 256m –d start
如果memcached 使用的内存超过了定义的内存,就会把最不常用的内存删除,该算法是LRU
如果你希望换一个端口
memcached -d -m 30 -l 127.0.0.1 -p 9000 -d start 此命令不适用unix
转自:http://blog.163.com/xiao66_fei/blog/static/1099087642012911114848150/
 
                    
                     
                    
                 
                    
                
 
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号