GAE datastore design to store “like” mechanism for

2019-08-30 02:44发布

I'm using Google App Engine's datastore and looking for a design solution for "like" functionality for user's status (similair to Facebook "likes")

I've gone through the Sharding Counters concepts (https://developers.google.com/appengine/articles/sharding_counters) and found its good and suitable for counting number of likes where you can increment or decrement the count. But I want to store the userId who liked the status. So I tried the same sharding concepts to store userIds but facing the below issues, * First of all is it good to shard userId list like count? * If so when the user dislike it, I have remove the user id from shared list. To achieve this I need to traverse all the sharded datastore and do a userId check and remove

Any suggestions on this or alternative solutions to achieve it?

1条回答
成全新的幸福
2楼-- · 2019-08-30 03:39

Sharding doesnt apply for that case. Sharding is to avoid many writes to the same object in short time periods. Makes sense for a 'likes' counter since many people like the same post. Not the same when sgoring who liked what. Those objects only change per-user, many users dont share the same object. Just store those in a non sharded table like you would in sql.

查看更多
登录 后发表回答