博客
关于我
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实现substring函数功能(附完整源码)
    查看>>
    Objective-C实现SudokuSolver数独解决方案算法(附完整源码)
    查看>>
    Objective-C实现Sudoku数独游戏算法(附完整源码)
    查看>>
    Objective-C实现sum of arithmetic series算术级数之和算法(附完整源码)
    查看>>
    Objective-C实现sum of geometric progression几何级数之和算法(附完整源码)
    查看>>
    Objective-C实现sum of subset子集总和算法(附完整源码)
    查看>>
    Objective-C实现SumOfSubset子集总和为一个定值的算法(附完整源码)
    查看>>
    Objective-C实现support vector machines支持向量机算法(附完整源码)
    查看>>
    Objective-C实现SVM支持向量机算法(附完整源码)
    查看>>
    Objective-C实现SVM支持向量机(附完整源码)
    查看>>
    Objective-C实现sylvester西尔维斯特方程算法(附完整源码)
    查看>>
    Objective-C实现tabu search禁忌搜索算法(附完整源码)
    查看>>
    Objective-C实现tanh函数功能(附完整源码)
    查看>>
    Objective-C实现Tarjan 用于在有向图中查找强连通分量的算法(附完整源码)
    查看>>
    Objective-C实现TCP Server 多线程同时连接多个客户端(附完整源码)
    查看>>
    Objective-C实现TCP拥塞控制(附完整源码)
    查看>>
    Objective-C实现tcp网络通讯服务器+客户端(附完整源码)
    查看>>
    Objective-C实现temperature conversions温度转换算法(附完整源码)
    查看>>
    Objective-C实现Tenengrad梯度函数(附完整源码)
    查看>>
    Objective-C实现ternary search三元搜索算法(附完整源码)
    查看>>