准备知识
Redis是一款开源的内存数据结构存储库,被用于数据库,缓存,以及消息队列。支持的数据类型保存字符串,哈希,列表,集合。Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes with radius queries and streams. Redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster.
指令使用
1)登陆指令 $ redis-cli -h 192.168.58.138 -p 6379 -a “fengyuzaitu”
2)查看服务运行状态 127.0.0.1:6379> ping
3)(error) NOAUTH Authentication required. 127.0.0.1:6379> auth ‘fengyuzaitu‘
订阅指令使用
1)Psubscribe 命令订阅一个或多个符合给定模式的频道。每个模式以 * 作为匹配符,比如 it* 匹配所有以 it 开头的频道( it.news 、 it.blog 、 it.tweets 等等)。 news.* 匹配所有以 news. 开头的频道( news.it news.global.today 等等),诸如此类。
redis 127.0.0.1:6379> PSUBSCRIBE USER_POSITION_INFO*
2)Subscribe 命令用于订阅给定的一个或多个频道的信息。。
redis 127.0.0.1:6379> SUBSCRIBEUSER_POSITION_INFO
注意:Psubscribe订阅的主题必须带*,这个跟Subscribe完全不一样
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/186120.html