telnet连接memcached
查看端口是否可访问
# telnet 172.16.1.1 11211 Trying 172.16.1.1... Connected to 172.16.1.1. Escape character is '^]'. ^]
添加获取数据
添加语法set没有值的时候添加,有值的时候修改
set key flags exptime bytes [noreply]
value
- key:键值 key-value 结构中的 key,用于查找缓存值。
- flags:可以包括键值对的整型参数,客户机使用它存储关于键值对的额外信息 。
- exptime:在缓存中保存键值对的时间长度(以秒为单位,0 表示永远)
- bytes:在缓存中存储的字节数
- noreply(可选): 该参数告知服务器不需要返回数据
- value:存储的值(始终位于第二行)(可直接理解为key-value结构中的value)
set username 0 60 3 abc STORED get username VALUE username 0 3 abc END
删除
delete username # 没有提示说明删除成功
清除所有
flush all
查看memcached状态
# stats STAT pid 37102 STAT uptime 4644 STAT time 1581828962 STAT version 1.5.22 STAT libevent 2.1.11-stable STAT pointer_size 64 STAT rusage_user 0.434336 STAT rusage_system 0.283283 STAT max_connections 1024 STAT curr_connections 2 STAT total_connections 5 STAT rejected_connections 3 STAT connection_structures 3 STAT reserved_fds 20 STAT cmd_get 2 STAT cmd_set 4 STAT cmd_flush 0 STAT cmd_touch 0 STAT cmd_meta 0 STAT get_hits 2 STAT get_misses 0 STAT get_expired 0 STAT get_flushed 0 STAT delete_misses 2 STAT delete_hits 1 STAT incr_misses 0 STAT incr_hits 0 STAT decr_misses 0 STAT decr_hits 0 STAT cas_misses 0 STAT cas_hits 0 STAT cas_badval 0 STAT touch_hits 0 STAT touch_misses 0 STAT auth_cmds 0 STAT auth_errors 0 STAT bytes_read 305 STAT bytes_written 5921 STAT limit_maxbytes 67108864 STAT accepting_conns 1 STAT listen_disabled_num 0 STAT time_in_listen_disabled_us 0 STAT threads 4 STAT conn_yields 0 STAT hash_power_level 16 STAT hash_bytes 524288 STAT hash_is_expanding 0 STAT slab_reassign_rescues 0 STAT slab_reassign_chunk_rescues 0 STAT slab_reassign_evictions_nomem 0 STAT slab_reassign_inline_reclaim 0 STAT slab_reassign_busy_items 0 STAT slab_reassign_busy_deletes 0 STAT slab_reassign_running 0 STAT slabs_moved 0 STAT lru_crawler_running 0 STAT lru_crawler_starts 3060 STAT lru_maintainer_juggles 5967 STAT malloc_fails 0 STAT log_worker_dropped 0 STAT log_worker_written 0 STAT log_watcher_skipped 0 STAT log_watcher_sent 0 STAT bytes 70 STAT curr_items 1 STAT total_items 4 STAT slab_global_page_pool 0 STAT expired_unfetched 0 STAT evicted_unfetched 0 STAT evicted_active 0 STAT evictions 0 STAT reclaimed 1 STAT crawler_reclaimed 0 STAT crawler_items_checked 1 STAT lrutail_reflocked 0 STAT moves_to_cold 4 STAT moves_to_warm 0 STAT moves_within_lru 0 STAT direct_reclaims 0 STAT lru_bumps_dropped 0 END