博客
关于我
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/

    你可能感兴趣的文章
    npm入门,这篇就够了
    查看>>
    npm切换到淘宝源
    查看>>
    npm前端包管理工具简介---npm工作笔记001
    查看>>
    npm升级以及使用淘宝npm镜像
    查看>>
    npm发布自己的组件UI包(详细步骤,图文并茂)
    查看>>
    npm和yarn清理缓存命令
    查看>>
    npm和yarn的使用对比
    查看>>
    npm学习(十一)之package-lock.json
    查看>>
    npm安装crypto-js 如何安装crypto-js, python爬虫安装加解密插件 找不到模块crypto-js python报错解决丢失crypto-js模块
    查看>>
    npm报错Failed at the node-sass@4.14.1 postinstall script
    查看>>
    npm报错unable to access ‘https://github.com/sohee-lee7/Squire.git/‘
    查看>>
    npm的安装和更新---npm工作笔记002
    查看>>
    npm的常用配置项---npm工作笔记004
    查看>>
    npm的问题:config global `--global`, `--local` are deprecated. Use `--location=global` instead 的解决办法
    查看>>
    npm编译报错You may need an additional loader to handle the result of these loaders
    查看>>
    npm设置淘宝镜像、升级等
    查看>>
    npm配置安装最新淘宝镜像,旧镜像会errror
    查看>>
    npm错误 gyp错误 vs版本不对 msvs_version不兼容
    查看>>
    npm错误Error: Cannot find module ‘postcss-loader‘
    查看>>
    NPOI之Excel——合并单元格、设置样式、输入公式
    查看>>