Forum BigDB Cron job type feature?

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

Cron job type feature?

Postby moosemouse » January 4th, 2011, 3:08 pm

First, I am very much a novice when it comes to databases so I may be using incorrect terminology or have other embarrassing misunderstandings.

I have a racing game with an option to create private races. A player can create a private race and get a secret entry code to send to his friends. The secret code will allow them to join the private race. So, I have created a table in BigDB called "PrivateRaces" which holds the necessary info to generate each private race: number of racers, number of laps, track number, etc.

But I would like these private races to only be available for 48 hours. After that I would like to delete them from the database. I have used PHP + MYSQL a little bit, and I know this kind of thing can be done automatically with a "cron job". Is there anything similar available to me with BigDB? Or is there a better way to do this?

Thanks in advance,
Shawn
User avatar
moosemouse
Paid Member
 
Posts: 83
Joined: August 11th, 2010, 2:51 pm
Location: New Albany, Ohio USA

Re: Cron job type feature?

Postby TobiasW » January 4th, 2011, 3:19 pm

Hello Shawn,

is
a) some action immediately to be taken when the race is to be deleted, or
b) should only be guaranteed that there are never too much races in the Database / players never join races older than 48h?

If it is the first, you might need some kind of special client which gets executed on some privat server you have - or have a fairly active user base to use my other advice down there to check regularly.

If it is the second, you might check on creation of a new race if any races are old enough to be deleted and if a user trys to open a race, check if it is too old and delete it then instead of giving it to him.

Cheers,
Tobias
User avatar
TobiasW
 
Posts: 59
Joined: August 29th, 2010, 12:31 am

Re: Cron job type feature?

Postby moosemouse » January 4th, 2011, 3:55 pm

Thanks for the ideas, Tobias. My main reasons for deleting the races are:

1. Time limits will (hopefully) create a sense of urgency that motivate people to play the game.
2. Each BigDB object costs me a little bit of money, so I don't want to have too many of them around.

So, actually deleting the BigDB object is only necessary for reason #2. Your second idea will work very well to handle reason #1.

Most likely I won't be running up against the 250,000 object limit any time soon.. so this is mainly just a housekeeping exercise. I can also run a script manually every week/month or so to handle this for a while. The private server solution sounds too complicated for me at this point in time.

Thanks!
Shawn
User avatar
moosemouse
Paid Member
 
Posts: 83
Joined: August 11th, 2010, 2:51 pm
Location: New Albany, Ohio USA

Re: Cron job type feature?

Postby TobiasW » January 4th, 2011, 4:53 pm

Hey Shawn,

actually the second solution works well for both of your reasons - remember, it consisted of two parts:

1) On creation of a new race, check if there are any old races to be deleted and delete them.
2) On access of a race, check if it is valid anymore or has to be deleted.

If you have many people creating races, pruning will be executed very often (thus freeing necessary space), if people create races fairly seldom, pruning won't be necessary too often.

A private server to execute a cronjob would only be necessary if, for example, you want to send out mails exactly when a race is expired.

Cheers,
Tobias
User avatar
TobiasW
 
Posts: 59
Joined: August 29th, 2010, 12:31 am

Re: Cron job type feature?

Postby moosemouse » January 5th, 2011, 1:14 pm

True! The only problem left is if a private race is completely abandoned and no one ever tries to join it. In this case it will never be deleted. For now I can manually run every so often to delete old private race objects.

Thanks!
Shawn
User avatar
moosemouse
Paid Member
 
Posts: 83
Joined: August 11th, 2010, 2:51 pm
Location: New Albany, Ohio USA

Re: Cron job type feature?

Postby Oliver » January 5th, 2011, 1:17 pm

If you have an index on the date column, you can execute a BigDB delete range operation that will delete all old games in one operation.

You could figure out someway to only run this operation once a day for instance..
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: Cron job type feature?

Postby moosemouse » January 5th, 2011, 1:24 pm

I just re-read your post.. you are right, I just read it wrong. If I have any new game creation also check to delete any old games it will be automatic, too. That is what I will do.
User avatar
moosemouse
Paid Member
 
Posts: 83
Joined: August 11th, 2010, 2:51 pm
Location: New Albany, Ohio USA


Return to BigDB



cron