• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

memcached命令知识

武飞扬头像
langy1990
帮助1

memcached安装配置     

      yum install memcached
      memcached最大的缓存单位为1M,大于1M的单项数据将不会缓存
      memcached是基于文本协议的,所以可以用telnet命令直接进行与其进行交互
      memcached默认没有安全认证机制

      要想操作redis或者memcached服务器 必须首先安装相关客户端工具库

[root@localhost myapp]# yum install telnet
#查看memcached帮助手册支持的数据类型
[root@localhost ~]# less /usr/share/doc/memcached-1.4.15/protocol.txt
#使用telnet充当memcached的客户端
[root@localhost myapp]# telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
stats
STAT pid 22529
STAT uptime 403
STAT time 1531906347
#memcached指定30字节长度后就必须存储30个字节的内容
#大于或者小于30个字节都会导致存储失败
#错误示例
add mykey 1 120 30
  www.百度.com
get mykey

#正确示例
set m 1 60 5 
aaaaa
STORED
get m
VALUE m 1 5
aaaaa
END

操作memcached

memcached命令类型

    统计类:stats, stats items, stats slabs, stats sizes
    存储类:set, add, replace, append, prepend
   命令格式:<command name> <key> <flags> <exptime> <bytes>
                     <cas unique>
   检索类:get, delete, incr/decr
   清空:flush_all

   示例:
           telnet> add KEY <flags> <expiretime> <bytes> \r
           telnet> VALUE

memcahed程序的常用选项

     -m <num>:Use <num> MB memory max to use for object storage; the default is 64 megabytes.
     -c <num>: Use <num> max simultaneous connections; the default is 1024.
     -u <username>:以指定的用户身份来运行进程;
     -l <ip_addr>:监听的IP地址,默认为本机所有地址;
     -p <num>:监听的TCP端口, the default is port 11211.
     -U <num>:Listen on UDP port <num>, the default is port 11211, 0 is off.
     -M:内存耗尽时,不执行LRU清理缓存,而是拒绝存入新的缓存项,直到有多余的空间可用时为止;
     -f <factor>:增长因子;默认是1.25;
     -t <threads>:启动的用于响应用户请求的线程数;

     memcached默认没有认证机制,可借用于SASL进行认证;
     SASL:Simple Authentication Secure Layer

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhibgach
系列文章
更多 icon
同类精品
更多 icon
继续加载