Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URlyBird v. 1.3.3 & caching

 
Jari Timonen
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Roel De Nijs
Sheriff
Posts: 10225
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jari Timonen
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 10225
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh yeah. Good. Then i'mm go with choise number 2)
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Jari Timonen
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic