aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes URlyBird v. 1.3.3 & caching Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "URlyBird v. 1.3.3 & caching" Watch "URlyBird v. 1.3.3 & caching" New topic
Author

URlyBird v. 1.3.3 & caching

Jari Timonen
Ranch Hand

Joined: Jan 16, 2004
Posts: 230
All of you who have done DB caching, how did you manage the part that some other program still reads/writes to same file?

1) Ignore it, use 100% caching, and try to explain in choises.txt (data is old and might be obsolete)
2) Make readcache and use observer design pattern to refresh it when writing. (somewhat possibility that data is old)
3) Don't use caching (possibility that data is old is minor)

?

Or i'm I just thinking too far?


SCJP 5.0, SCJD URLyBird 1.3.3, OCMJEA 5 (SCEA) Factory Homes
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5212
    
  12

Hi Jari,

My instructions state:

You may assume that at any moment, at most one program is accessing the database file;


so one your program starts no other program is accessing the file to read/write


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Jari Timonen
Ranch Hand

Joined: Jan 16, 2004
Posts: 230
Roel De Nijs wrote:Hi Jari,

My instructions state:

You may assume that at any moment, at most one program is accessing the database file;


so one your program starts no other program is accessing the file to read/write


Ok. I was little unsure about that sentence... So it means, that no other program is accessing the file?
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5212
    
  12

That is indeed my interpretation. if our program starts no other program will use the file during the run of our program.
Jari Timonen
Ranch Hand

Joined: Jan 16, 2004
Posts: 230
Oh yeah. Good. Then i'mm go with choise number 2)
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2264
    
    3

Hello, Jari!

Just to give you a position, I used caching, that is, when the application starts, I place all records in memory, and when it finishes, I write them all back to the .db file. But I didn't use the observer pattern, because it isn't really necessary. What I did is, the records being displayed to the users are refreshed every time they call the server. For instance, if you have records 1, 2 and 3 being displayed, I update record 2, then you update record 3, then record 2 will be updated in your screen only when you update record 3.

Also, it is exactly what you guys are saying. It is only our application accessing the .db file. So, you can use caching without any problems and not worry about the file being updated out of your application and messing up the records!


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Jari Timonen
Ranch Hand

Joined: Jan 16, 2004
Posts: 230
Roberto Perillo wrote:Hello, Jari!

Just to give you a position, I used caching, that is, when the application starts, I place all records in memory, and when it finishes, I write them all back to the .db file. But I didn't use the observer pattern, because it isn't really necessary. What I did is, the records being displayed to the users are refreshed every time they call the server. For instance, if you have records 1, 2 and 3 being displayed, I update record 2, then you update record 3, then record 2 will be updated in your screen only when you update record 3.

Also, it is exactly what you guys are saying. It is only our application accessing the .db file. So, you can use caching without any problems and not worry about the file being updated out of your application and messing up the records!


Thanks for input. That's quite straght forward. This assignment is getting easier every minute

Did you white changed information or emptied whole file and wrote it according to schema?
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2264
    
    3

Hummm not really, I don't erase the whole file. Since records are not physically deleted from the file, then I just write the records back, and the flags of the deleted records are updated accordingly.
Jari Timonen
Ranch Hand

Joined: Jan 16, 2004
Posts: 230
Roberto Perillo wrote:Hummm not really, I don't erase the whole file. Since records are not physically deleted from the file, then I just write the records back, and the flags of the deleted records are updated accordingly.


Oh yeah, sorry. Forgot that gui does not have create button. Only Data-class.
 
Consider Paul's rocket mass heater.
 
subject: URlyBird v. 1.3.3 & caching