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

    你可能感兴趣的文章
    NutzWk 5.1.5 发布,Java 微服务分布式开发框架
    查看>>
    NUUO网络视频录像机 css_parser.php 任意文件读取漏洞复现
    查看>>
    NuxtJS 接口转发详解:Nitro 的用法与注意事项
    查看>>
    NVelocity标签使用详解
    查看>>
    Nvidia Cudatoolkit 与 Conda Cudatoolkit
    查看>>
    NVIDIA GPU 的状态信息输出,由 `nvidia-smi` 命令生成
    查看>>
    NVIDIA-cuda-cudnn下载地址
    查看>>
    nvidia-htop 使用教程
    查看>>
    nvidia-smi 参数详解
    查看>>
    nyoj58 最少步数
    查看>>
    OAuth2 + Gateway统一认证一步步实现(公司项目能直接使用),密码模式&授权码模式
    查看>>
    OAuth2 Provider 项目常见问题解决方案
    查看>>
    Vue.js 学习总结(14)—— Vue3 为什么推荐使用 ref 而不是 reactive
    查看>>
    oauth2-shiro 添加 redis 实现版本
    查看>>
    OAuth2.0_JWT令牌-生成令牌和校验令牌_Spring Security OAuth2.0认证授权---springcloud工作笔记148
    查看>>
    OAuth2.0_JWT令牌介绍_Spring Security OAuth2.0认证授权---springcloud工作笔记147
    查看>>
    OAuth2.0_介绍_Spring Security OAuth2.0认证授权---springcloud工作笔记137
    查看>>
    OAuth2.0_完善环境配置_把资源微服务客户端信息_授权码存入到数据库_Spring Security OAuth2.0认证授权---springcloud工作笔记149
    查看>>
    OAuth2.0_授权服务配置_Spring Security OAuth2.0认证授权---springcloud工作笔记140
    查看>>
    OAuth2.0_授权服务配置_令牌服务和令牌端点配置_Spring Security OAuth2.0认证授权---springcloud工作笔记143
    查看>>