if i have 2 "Tables",
"Table Player" , (Fields - PlayerKey, PlayerName, PlayerUrlPhoto) "Table PlayerGames", (Fields - PlayerGameKey, PlayerKey, GameDate)
if i wanna list all games, i will create a query in "PlayerGames", and to show the "Players" info, i will have to "GetObjectbyID" to read PlayerName and PLayerUrlPhoto.
What is the best way to do this?
1 - Using GetObjectByID is the right way (spending 1 "datastore read" more for each "PlayerGame" record) 2 - Store at "PlayerGames" the fields that i know that i will need to list in the future? (as playername and playerurlphoto, Saving the "DataStore read" to get Player info) 3 - Other way...
Can someone give me a tip about this?
thx
It sounds like you just need to use memcache in front of your entities. When you're getting Player entities by key, first check the memcache using a key you calculate from the datastore key, and if there's a value there, use it. Otherwise, perform the datastore read, then store the result in the memcache for future use. This will drastically reduce the number of datastore reads.
When the player updates her record, just delete the memcache value after updating the datastore record. This forces the next read to go to the datastore, and update the cache.