zoukankan      html  css  js  c++  java
  • Memcached 命令行操作

    telnet 用于连接 Memcached:

    [root@localhost ~]# telnet 127.0.0.1 11211
    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is '^]'.
    quit


    set 用于向缓存中添加新的键值对,如果键已经存在,则之前的值将被替换

    set name 0 30 3    //设置key规则,name表示key的名字;0是一个标记,也就是这个键值对的额外信息;30表示过期时间为30秒,如果设置成0则表示永久缓存;3表示存储的字节数
    Tom                //存储value值为Tom,因为Tom的字节数为3,所以存储成功,返回STORED,表示已经存储进去了;如果我们存储的值为John则会失败,返回ERROR
    STORED
    John
    ERROR


    add 用于向缓存中添加新的键值对,仅当缓存中不存在键时,add 命令才会向缓存中添加一个键值对,如果已经存在则响应 NOT_STORED

    add name 0 0 4
    John
    STORED


    replace 用于替换缓存中已存在的key对应的value值,如果key不存在则相应 NOT_STORED

    replace name 0 0 4
    Jeny
    STORED


    get 用于获取指定 key 对应的 value 值

    get name
    VALUE name 0 4
    Jeny
    END


    delete 用于删除指定的键值对,如果指定的 key 不存在,则响应 NOT_FOUND

    delete name
    DELETED
    delete name
    NOT_FOUND


    stats 用于查看 Memcached 实例的统计数据

    stats
    STAT pid 122430
    STAT uptime 5077
    STAT time 1551494568
    ...... END


    flush_all 用于清空所有缓存数据

    flush_all
    OK

           

  • 相关阅读:
    Merge Two Sorted Lists
    4Sum
    Letter Combinations of a Phone Number
    3Sum Closest
    3Sum
    Longest Common Prefix
    Roman to Integer
    Integer to Roman
    Container With Most Water
    Regular Expression Matching
  • 原文地址:https://www.cnblogs.com/pzk7788/p/10460083.html
Copyright © 2011-2022 走看看