2 ms·
Make a very simple database model with at least these columns: comment_id int, created timestamp, parent int, score int,... When you need to view a page of com
by tim2 19y ago
Make a very simple database model with at least these columns: comment_id int, created timestamp, parent int, score int,...
When you need to view a page of comments that has not been loaded, load it into cache and then use your cache from there on out. When updates come in, write them directly to the cache, re-sort the cache as necessary, and then have the database updates run in the background.
For the cache tree model I use something like:
{'root_comment_id':123,'children_sorted_by_points':[]}
Cache expiration left as an exercise for you.
This can very easily handle something the size of hacker news.
edit: And this easily handles "many reads and many writes and an ever-changing order".