This article brings you relevant knowledge about redis. It mainly shares with you the idea of redis multi-dimensional ranking. Friends who are interested can take a look at it together. I hope it will be helpful to everyone.
Problem Description
#As we all know, redis zset is often used in rankings and can be done right out of the box Use it, but it has a disadvantage, that is, it only supports single-dimensional rankings.
However, in actual projects, single-dimensional ranking is indeed very impractical. A simple example is walking ranking. The product requirement is to rank and sort based on the number of steps, completion time, and person’s name. Priority is from left to right.
Specific solution ideas
Number of steps: Originally it is a number and can be ignored
Personal names: Personal names are generally composed of Chinese characters or letters. Chinese characters and letters are both strings. When we want to sort, the first step is to convert the strings into numbers. It is recommended to use PHP for this process. Native functionmb_ord.
In the actual process of obtaining the value, we can remove the decimal point. The number after the decimal point is only used for ranking.
Recommended learning: "Redis Video Tutorial"
The above is the detailed content of Share redis multi-dimensional ranking ideas. For more information, please follow other related articles on the PHP Chinese website!