Forum BigDB PlayerObject Caching

Discussion and help relating to the PlayerIO database solution, BigDB.

PlayerObject Caching

Postby groomi » August 25th, 2013, 3:21 pm

Are playerObjects cached on a per-room basis?

The reason I ask, I have currently locked down my app to 1 room per player but in the future it would be good if I could have a player join more than 1 room, but also have effects on BigDB be shared globally.

Let me try to explain:

Player x has 1,000 points
He joins room 1 which has preloadPlayerObjects set to true. room 1 now sees his score as 1,000
He then loses 100 points in room1 and it is dealt with using a PlayerObject.Set() and a PlayerObject.Save()
I can now see that both in room1, and BigDB in the player.io admin panel the `score` field is set to 900.
However, if I were to now set the `score` field from the player.io admin panel to 800, and then run PlayerObject.GetInt() from within room1, the score is still shown at 900.

Do I need to run GetPlayerObject() every time I run GetInt() for it to update changes made in other servers or via the web interface?
Is this resource intensive?

Thanks
S
groomi
Paid Member
 
Posts: 46
Joined: January 15th, 2013, 5:14 pm

Re: PlayerObject Caching

Postby romeoordos » August 25th, 2013, 6:49 pm

If you need to modify DatabaseObjects in different places, you should load it every time before save it back to DB.
romeoordos
Paid Member
 
Posts: 9
Joined: July 27th, 2013, 10:42 am

Re: PlayerObject Caching

Postby groomi » September 16th, 2013, 7:08 pm

The word 'load' isn't very informative. What function are you referring to when you say you would 'load' some data?
groomi
Paid Member
 
Posts: 46
Joined: January 15th, 2013, 5:14 pm

Re: PlayerObject Caching

Postby Benjaminsen » September 16th, 2013, 7:29 pm

Yes BigDB objects are represented locally in memory for each multiplayer instance and are not synchronized.

To allow for slightly easier management of synchronized objects we implement the useOptimisticLocks property, which will result in an error on save, if the object has been modified on the server compared to the local object.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: PlayerObject Caching

Postby groomi » September 16th, 2013, 7:34 pm

Ok, Thanks Benjaminsen.

So if UseOptimisticLocks fails, what would I then to to synchronise the objects?
groomi
Paid Member
 
Posts: 46
Joined: January 15th, 2013, 5:14 pm

Re: PlayerObject Caching

Postby Luischo » October 22nd, 2013, 2:09 am

If you fail, is because data is already updated on server, so, normally you re read data, and then you decide if you change again that data and how is saved.
Luischo
 
Posts: 3
Joined: November 25th, 2012, 1:31 am

Re: PlayerObject Caching

Postby Benjaminsen » October 22nd, 2013, 5:21 pm

Luischo wrote:If you fail, is because data is already updated on server, so, normally you re read data, and then you decide if you change again that data and how is saved.


What this guy said, load the object again, reapply your changes if you need, save.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: PlayerObject Caching

Postby groomi » October 22nd, 2013, 8:41 pm

Ty
groomi
Paid Member
 
Posts: 46
Joined: January 15th, 2013, 5:14 pm


Return to BigDB



cron