Hi all,
My database object (one per client) has some static lists holding records etc. When (and how) should I persist any updates to disk? At the minute I'm doing it with every option thats changing data but it means lots of I\O, but on the other hand is safer in case of the server crashing and changes getting lost for example (could this be a reason for keeping with my design?).
Also,
My database constructor populates the static lists, by reading the file:
class Database
{
static List records = new ArrayList();
public Database
{
try{
//read file, and add to records
}
catch{}
}
}
Now, take this scenario:
Client A connects, creates first database instance and static list gets populated, Client A then updates the Static list.
At the same time client B connects, before Client A persists changes to file.
Because client B created its database object before Client A updated the file the static list is repopulated with old data.
Basically i need suggestions as to how, after initial db object creation, I can stop subsequent database objects re-populating my static list. I dont see how i can take the try\catch clause out of the constructor.
Thanks.