作者的原文链接:http://huoding.com/2012/02/29/146
redis初学者,轻喷,下面可能很多错误,是我的大致理解:
他首先创建一个需要收到消息的用户的队列
再创建了一个有消息重要等级消息队列
然后创建了一个用户id和消息id关联的队列
然后他用redis命令行做演示:
首先创建了一个消息的hash表
然后创建了类似于上面的用户id和消息id关联的集合
最后通过SORT模拟关联查询渠道消息内容
但是这些内容我用PHP数组+mysql也能实现啊?
为什么要用redis呢?
到底优势在哪里呢?
为什么redis适合于这样的场景呢?
消息发送完毕之后又如何做持久化存储呢?
说明的越详细越好,谢谢了。
ringa_lee2017-04-21 11:18:45
Of course you can also achieve it using MYSQL, but
1. In terms of data operations, redis (should be NOSQL) is faster than regular MYSQL. Because MYSQL needs to go through many processes to process data, such as SQL parsing, etc.
2. Redis supports a variety of data structures, such as the ordered set zSet and list mentioned in the article. A software natively provides them, so you don’t have to implement these data structures yourself, saving you time.
3.Redis itself supports persistent storage. If you are worried about losing it, backup it to MYSQL.
4...You can understand other things slowly, it is best to think about it while using it
PHPz2017-04-21 11:18:45
The choice of database should be linked to your needs. If the number of messages you push is hundreds or thousands, the advantages of using redis are indeed invisible. But if the number of push messages reaches millions or tens of millions, redis will The advantages will be obvious.
The same is sorting. How is the difference between bubbling and quick sorting reflected? The significance of algorithms and data structures will be reflected when the input scale is large.
For everything about redis, just go to google