System recommendation algorithm: according to the rules of each person, random recommendation is required, and each recommendation is different. How can this problem be achieved? Redis, mysql? System recommendation algorithm:
According to the rules of each person, random recommendation is required, and each recommendation is different. How can this problem be achieved?
Redis, mysql?
Reply content:
System recommendation algorithm:
According to the rules of each person, random recommendation is required, and each recommendation is different. How can this problem be achieved?
Redis, mysql?
We recommend that you use Redis to Mark recommended items with hash-type key-value. The next recommendation result will be compared in Redis. If not, the recommendation result will pass and be marked.
The Hash performance is much higher than that of SQL retrieval. Therefore, when we select Redis, the request time can be reduced to a single digit in ms and deployed to a dedicated Redis server without occupying the mysql load. The best choice is currently.
Of course redis preferred
It is not clear about your specific use cases. We suggest using this method.
You can use the redis set to randomly obtain your recommendation from the set.
Then, remove the retrieved data from the set to avoid repeated recommendations.
If it is not a massive amount of data, you can design a structure to achieve the functions you need:
A recommender and a table with recommended relationships,
Required: recommender, recommendation id
Random recommendation is not a problem. Create an algorithm by yourself (find the replacement algorithm of order by rand) it is good to find the recommendation that satisfies the number of items-it is nothing more than to exclude the previous recommendation (there are already table records ).
Therefore, you only need to record the id of the person who found the personal recommendation last time.