*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX:Reading/Writing DB file vs. Caching Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX:Reading/Writing DB file vs. Caching" Watch "NX:Reading/Writing DB file vs. Caching" New topic
Author

NX:Reading/Writing DB file vs. Caching

ulvi ugur
Ranch Hand

Joined: Aug 05, 2003
Posts: 46
Hi All,
I see two alternatives about handling DB file.
1- For each request reading/writing DB file and do all actions on the file.
2- Cache the DB in memory and whenever necessary write cache contents in DB.
The latter is more interesting for me since
A- Search actions would be much easier rather than dealing with the file
B- For every update I would create a thread to do the task.(How ?)
What do you think ? Any point I'm missing ?
Vlad Rabkin
Ranch Hand

Joined: Jul 07, 2003
Posts: 555
Hi Ulvi,

A- Search actions would be much easier rather than dealing with the file
B- For every update I would create a thread to do the task.(How ?)

I personally use cash, but not because of the reasons mentioned by you.
I use cash for better performance. Drawback is memory overhead, but memory is cheap.
A. Search actions would be easier, but other issues could become a bit more complicated (e.g. synchronitazion), depending on your design. So my personal opinion is , that using cash just to have more simplicity, is not an important reason.
B. It depends on your design. I do not create any threads by myself (I use RMI Server and it does create by itself). Could please describe your design that I could understand better your question.
Regards,
Vlad
ulvi ugur
Ranch Hand

Joined: Aug 05, 2003
Posts: 46
Hi Vlad,
Right now I am actually trying to design the whole thing. My current thread is about the class which is going to be used by the server(and GUI in stand-alone mode). At this stage I don't think that I need to make a decision about the communication between the client and the server. (Although I am very interested what the factors for you to use RMI are)
My point about caching when I say "simple" is so :
1- If I synchronize all requests (search/update/delete) then I would prevent dirty reads. Might be difficult to implement but easier to understand.
2- For search operations, I don't need to read the file again, I only need to search in the recordset I already have.
What do you think ?
Vlad Rabkin
Ranch Hand

Joined: Jul 07, 2003
Posts: 555
Hi Ulvi,

1- If I synchronize all requests (search/update/delete) then I would prevent dirty reads. Might be difficult to implement but easier to understand.
2- For search operations, I don't need to read the file again, I only need to search in the recordset I already have.


1. You can synchronize all requests without caching.
2. Agree
So, the point is performance, not simplicity.
I use RMI, because it hides network protocol from implementation. So it is easier for me and for somebody who wants to understand business logic of my program, instead of technical details.
Disadvantage is: I do have poor control over the thread creation for remote clients, but I designed my program so, that it doesn't care about it.
Regards,
Vlad
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NX:Reading/Writing DB file vs. Caching
 
Similar Threads
Data Class Doing Too Much?
Writing to DB file
(B&S)The Update() method
NX: [URLyBird] Problem about synchronize mechanism
Writing to .DB with RandomAccessFile