Hi, My requirements include a system that can handle friend based highscore lists (as a user I have a bunch of friends from various social sites like Facebook). The user must have a highscore list that consist of his friends only.
I have implemented this using the users ID as partition key and the friends score and id as clustering keys. This keeps reads of the highscore list fast and straight forward. Updating a highscore is a bit cumbersome and suffers from read-before-write, but can largely be done without too much worry. The big issue here is I need to know the exact old highscore to be able to set a new one. The big problem arise when a new user connects and have many friends that needs to be added. This can end up being quite an extensive amount of queries that has to happen and could take some time to do: - Lookup the friends user id based on the social credentials - Lookup the friends highscore - Lookup the users own highscore - Add friend with his highscore to self - Add self to with own highscore to friend - Do update to self with lastUpdatedFriends timestamp - Do update to friend with lastUpdatedFriends timestamp Now if a new user has a bunch of friends this could end up being quite a lot of queries - all suffering from the read-before-write problem. Should any of the friends set a new highscore between the lookup and the writes the highscore would never be set correctly and duplicates would happen. I'm open to any suggestions ranging from how to model this differently to avoid the read-before-write to how to do this without risking having duplicate data that would be extremely painful to try and find again in highscore lists? Thanks, Kasper