I use DjangoREST & MySQL as a backend for a mobiel app. I have two models, User and Feed and for any call to api/feeds/ returns all feeds for authenticated user ordered by created_at parameter of feed.
However, I need to customize order of feeds for each user by simple scoring algorithm. Details of algorithm is not important but I basically need to store score for each card-feed pair in table like UserFeedScore.
The problem is this table will grow very fast when the number of user and feeds are increasing because there will be a row for each user - feed pair. Besides, for each user activity (like, comment etc) scores for each feed for that user will be updated which will exhaust MySQL db eventually.
Keeping this table in Redis seems like a proper solution but I'm not sure how I order the feeds in MySQL database by the scores calculated in Redis.
Any Redis data structure, key-value suggestions and Django query examples are appreciated.
class Feed(models.Model): text = models.CharField() created_by = models.ForeignKey(settings.AUTH_USER_MODEL) created_at = models.DateTimeField(default=timezone.now) class UserFeedScore(models.Model) user = models.ForeignKey(settings.AUTH_USER_MODEL) feed = models.ForeignKey(Feed) score = models.IntegerField(default=100)