System recommendation algorithm:
According to each person's rules, need to carry out random recommendation, and each recommendation is different, how to achieve?
Redis, MySQL?
Reply content:
System recommendation algorithm:
According to each person's rules, need to carry out random recommendation, and each recommendation is different, how to achieve?
Redis, MySQL?
It is recommended to use the Redis implementation to mark the recommended items with a hash type of key-value, and the next recommendation results are compared in Redis and are not recommended for adoption and tagging.
Hash performance is much higher than SQL retrieval, so choose Redis, request time can be reduced to Ms single-digit, deployed to a dedicated Redis server, can not occupy the MySQL load, the best choice.
Of course Redis preferred
Not clear about your specific usage scenarios, suggest a way to use
You can use the collection of Redis to randomly fetch your recommendation from the collection.
Then remove the data from the collection to protect it from repeated recommendations.
If it's not a huge amount of data, you can design a structure to achieve the functionality you need:
A referrer and a table of recommended relationships,
Need something: referrer, referral ID
Random recommendation is not a problem, make an algorithm (find the Order by rand () replacement algorithm) to find out to satisfy the recommendation of the number of bars-nothing more than the previous recommendation (there is already a table record).
So you just need to record the last time you find a personal referral ID.