memcached快速使用
2021/7/21 6:06:03
本文主要是介绍memcached快速使用,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
环境
ubuntu 20.04
memcached安装
sudo apt install memcached
启动,重启,状态
service memcached status service memcached start service memcached restart
终端连接和退出
telnet 127.0.0.1 11211
quit
set 命令 语法
set key flags exptime bytes [noreply] value
参数
key:键值 key-value 结构中的 key,用于查找缓存值。 flags:可以包括键值对的整型参数,客户机使用它存储关于键值对的额外信息 。 exptime:在缓存中保存键值对的时间长度(以秒为单位,0 表示永远) bytes:在缓存中存储的字节数 noreply(可选): 该参数告知服务器不需要返回数据 value:存储的值(始终位于第二行)(可直接理解为key-value结构中的value)
实例
set name 0 300 10 huyongjian STORED get name VALUE name 0 10 huyongjian END
add 命令
add key1 0 300 6 value1 STORED get key1 VALUE key1 0 6 value1 END
replace 命令
replace key1 0 300 8 value111 STORED get key1 VALUE key1 0 8 value111 END
append 命令
append key1 0 300 10 huyongjian STORED get key1 VALUE key1 0 18 value111huyongjian END
prepend 命令
prepend key1 0 300 4 name STORED get key1 VALUE key1 0 22 namevalue111huyongjian END
get 命令
get key1
get key1 key2
gets 命令
gets key
delete 命令
delete key [noreply]
delete key1 DELETED
incr 命令
语法
incr key increment_value
set key1 0 900 1 1 STORED incr key1 5 6 get key1 VALUE key1 0 1 6 END
decr 命令
语法
decr key decrement_value
get key1 VALUE key1 0 1 6 END decr key1 3 3
stats 命令
stats STAT pid 1848611 STAT uptime 2291 STAT time 1626806924 STAT version 1.5.22 STAT libevent 2.1.11-stable STAT pointer_size 64 STAT rusage_user 0.170337 STAT rusage_system 0.208419 STAT max_connections 1024 STAT curr_connections 1 STAT total_connections 4 STAT rejected_connections 3 STAT connection_structures 2 STAT reserved_fds 20 STAT cmd_get 16 STAT cmd_set 11 STAT cmd_flush 0 STAT cmd_touch 0 STAT cmd_meta 0 STAT get_hits 13 STAT get_misses 3 STAT get_expired 1 STAT get_flushed 0 STAT delete_misses 0 STAT delete_hits 1 STAT incr_misses 0 STAT incr_hits 1 STAT decr_misses 0 STAT decr_hits 1 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 631 STAT bytes_written 722 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 2295 STAT lru_maintainer_juggles 4257 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 129 STAT curr_items 2 STAT total_items 8 STAT slab_global_page_pool 0 STAT expired_unfetched 0 STAT evicted_unfetched 0 STAT evicted_active 0 STAT evictions 0 STAT reclaimed 0 STAT crawler_reclaimed 1 STAT crawler_items_checked 9 STAT lrutail_reflocked 0 STAT moves_to_cold 13 STAT moves_to_warm 5 STAT moves_within_lru 0 STAT direct_reclaims 0 STAT lru_bumps_dropped 0 END
pid: memcache服务器进程ID uptime:服务器已运行秒数 time:服务器当前Unix时间戳 version:memcache版本 pointer_size:操作系统指针大小 rusage_user:进程累计用户时间 rusage_system:进程累计系统时间 curr_connections:当前连接数量 total_connections:Memcached运行以来连接总数 connection_structures:Memcached分配的连接结构数量 cmd_get:get命令请求次数 cmd_set:set命令请求次数 cmd_flush:flush命令请求次数 get_hits:get命令命中次数 get_misses:get命令未命中次数 delete_misses:delete命令未命中次数 delete_hits:delete命令命中次数 incr_misses:incr命令未命中次数 incr_hits:incr命令命中次数 decr_misses:decr命令未命中次数 decr_hits:decr命令命中次数 cas_misses:cas命令未命中次数 cas_hits:cas命令命中次数 cas_badval:使用擦拭次数 auth_cmds:认证命令处理的次数 auth_errors:认证失败数目 bytes_read:读取总字节数 bytes_written:发送总字节数 limit_maxbytes:分配的内存总大小(字节) accepting_conns:服务器是否达到过最大连接(0/1) listen_disabled_num:失效的监听数 threads:当前线程数 conn_yields:连接操作主动放弃数目 bytes:当前存储占用的字节数 curr_items:当前存储的数据总数 total_items:启动以来存储的数据总数 evictions:LRU释放的对象数目 reclaimed:已过期的数据条目来存储新数据的数目
stats items 命令
stats items STAT items:1:number 2 STAT items:1:number_hot 0 STAT items:1:number_warm 0 STAT items:1:number_cold 2 STAT items:1:age_hot 0 STAT items:1:age_warm 0 STAT items:1:age 1455 STAT items:1:mem_requested 129 STAT items:1:evicted 0 STAT items:1:evicted_nonzero 0 STAT items:1:evicted_time 0 STAT items:1:outofmemory 0 STAT items:1:tailrepairs 0 STAT items:1:reclaimed 0 STAT items:1:expired_unfetched 0 STAT items:1:evicted_unfetched 0 STAT items:1:evicted_active 0 STAT items:1:crawler_reclaimed 1 STAT items:1:crawler_items_checked 11 STAT items:1:lrutail_reflocked 0 STAT items:1:moves_to_cold 13 STAT items:1:moves_to_warm 5 STAT items:1:moves_within_lru 0 STAT items:1:direct_reclaims 0 STAT items:1:hits_to_hot 0 STAT items:1:hits_to_warm 0 STAT items:1:hits_to_cold 13 STAT items:1:hits_to_temp 0 END
stats slabs 命令
stats slabs STAT 1:chunk_size 96 STAT 1:chunks_per_page 10922 STAT 1:total_pages 1 STAT 1:total_chunks 10922 STAT 1:used_chunks 2 STAT 1:free_chunks 10920 STAT 1:free_chunks_end 0 STAT 1:get_hits 13 STAT 1:cmd_set 11 STAT 1:delete_hits 1 STAT 1:incr_hits 1 STAT 1:decr_hits 1 STAT 1:cas_hits 0 STAT 1:cas_badval 0 STAT 1:touch_hits 0 STAT active_slabs 1 STAT total_malloced 1048576 END
stats sizes 命令
stats sizes STAT 96 1 END
flush_all 命令
get key1 VALUE key1 0 1 3 END flush_all OK get key1 END
这篇关于memcached快速使用的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-22怎么通过控制台去看我的页面渲染的内容在哪个文件中呢-icode9专业技术文章分享
- 2024-12-22el-tabs 组件只被引用了一次,但有时会渲染两次是什么原因?-icode9专业技术文章分享
- 2024-12-22wordpress有哪些好的安全插件?-icode9专业技术文章分享
- 2024-12-22wordpress如何查看系统有哪些cron任务?-icode9专业技术文章分享
- 2024-12-21Svg Sprite Icon教程:轻松入门与应用指南
- 2024-12-20Excel数据导出实战:新手必学的简单教程
- 2024-12-20RBAC的权限实战:新手入门教程
- 2024-12-20Svg Sprite Icon实战:从入门到上手的全面指南
- 2024-12-20LCD1602显示模块详解
- 2024-12-20利用Gemini构建处理各种PDF文档的Document AI管道