博客
关于我
Redis 高级特性(2)—— 发布 订阅模式
阅读量:503 次
发布时间:2019-03-07

本文共 1454 字,大约阅读时间需要 4 分钟。

Redis ???? ?? ????

1. ??-????

??-????????????????????????????????????????channel??????????????????????????????????????????


2. ??-????

????

???????????

publish channel message
  • channel??????????????
  • message??????

????

????????

subscribe channel [channel...]
  • channel?????????????????????????
  • [channel...]???????????????

3. ??-????

??????

?????????????????????????????????

  • subscribe?????????????

    • ???????????????
    • ??????????????????
  • message??????????

    • ???????????????
    • ??????????
  • unsubscribe?????????????????

    • ?????????????
    • ????????????????????? 0 ?????????????

  • ????

    ????

    # ??????? `channel`redis-cli -h 127.0.0.1 publish channel "hello"# ??????? `channel`redis-cli -h 127.0.0.1 publish channel "How are you"

    ????

    # ???? `channel`redis-cli -h 127.0.0.1 subscribe channel

    ????????????????????????

    # ????1) "subscribe"2) "channel"3) (integer) 11) "message"2) "channel"3) "How are you"

    ?????

    ???????????? psubscribe ???????????????

    # ????? `*` ?????redis-cli -h 127.0.0.1 psubscribe greets*

    ??????????????? greets ???????

    # ?????????redis-cli -h 127.0.0.1 publish greet1 "hello"redis-cli -h 127.0.0.1 publish greets_1 "hello"redis-cli -h 127.0.0.1 publish greets_2 "world"redis-cli -h 127.0.0.1 publish greets_3 "I am redis"

    ?????

    # ????1) "psubscribe"2) "greets*"3) (integer) 11) "pmessage"2) "greets*"3) "greets_1"4) "hello"1) "pmessage"2) "greets*"3) "greets_2"4) "world"1) "pmessage"2) "greets*"3) "greets_3"4) "I am redis"

    ?????????????? Redis ??-??????????????

    转载地址:http://njkjz.baihongyu.com/

    你可能感兴趣的文章
    Objective-C实现余数定理算法(附完整源码)
    查看>>
    Objective-C实现使用 2 个堆栈形成队列算法(附完整源码)
    查看>>
    Objective-C实现使用 radix-2 快速傅里叶变换的快速多项式乘法算法(附完整源码)
    查看>>
    Objective-C实现使用 ziggurat() 作为 OpenMP 并行程序中的随机数生成器 (RNG)(附完整源码)
    查看>>
    Objective-C实现使用DisjointSet 检测无向循环算法(附完整源码)
    查看>>
    Objective-C实现使用Prim算法确定图的最小生成树算法(附完整源码)
    查看>>
    Objective-C实现使用二元运算符将两个数字相加fullAdder算法(附完整源码)
    查看>>
    Objective-C实现使用分而治之找到单峰列表的峰值算法(附完整源码)
    查看>>
    Objective-C实现使用数组实现约瑟夫环(附完整源码)
    查看>>
    Objective-C实现使用矩阵求幂的第 n 个斐波那契算法(附完整源码)
    查看>>
    Objective-C实现使用管道重定向进程输入输出(附完整源码)
    查看>>
    Objective-C实现倒计时(附完整源码)
    查看>>
    Objective-C实现借记款项功能(附完整源码)
    查看>>
    Objective-C实现全年3天打渔,2天晒网(附完整源码)
    查看>>
    Objective-C实现八进制转十进制算法(附完整源码)
    查看>>
    Objective-C实现共享内存(附完整源码)
    查看>>
    Objective-C实现关机、重启、注销功能的实现(附完整源代码)
    查看>>
    Objective-C实现关机程序(附完整源码)
    查看>>
    Objective-C实现关系矩阵A和B的乘积(附完整源码)
    查看>>
    Objective-C实现关系矩阵乘法(附完整源码)
    查看>>