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

    你可能感兴趣的文章
    Nmap端口扫描工具Windows安装和命令大全(非常详细)零基础入门到精通,收藏这篇就够了
    查看>>
    NMAP网络扫描工具的安装与使用
    查看>>
    NN&DL4.1 Deep L-layer neural network简介
    查看>>
    NN&DL4.3 Getting your matrix dimensions right
    查看>>
    NN&DL4.8 What does this have to do with the brain?
    查看>>
    No 'Access-Control-Allow-Origin' header is present on the requested resource.
    查看>>
    No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
    查看>>
    No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
    查看>>
    No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
    查看>>
    No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
    查看>>
    No module named cv2
    查看>>
    No module named tensorboard.main在安装tensorboardX的时候遇到的问题
    查看>>
    No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
    查看>>
    No new migrations found. Your system is up-to-date.
    查看>>
    No qualifying bean of type XXX found for dependency XXX.
    查看>>
    No resource identifier found for attribute 'srcCompat' in package的解决办法
    查看>>
    No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
    查看>>
    NO.23 ZenTaoPHP目录结构
    查看>>
    NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
    查看>>
    Node JS: < 一> 初识Node JS
    查看>>