Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX:Another way of accessing database

 
HaoZhe Xu
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many people are using RandomAccessFile to access the database, can I just use a stream to read all the data in the database and store it in a structure, then it will be easy to search/book/modify it, because there're only 7 records in the database?
 
Suresh Bansal
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In that case, how do you plan to handle updates to the data by multiple clients.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi HaoZhe,
Several people here are caching the records in a similar manner. This will give you a system that will have better performance than one which accesses the hard drive for every operation.
I don't think Suresh's concern is a big issue: no matter which way you write your Data class you should be ensuring that only one instance of a class can access / modify the data at any given time. So if you were doing physical disk operations you might choose to have only one instance of the Data class (or a helper class for the Data class) which does all the disk operations - all clients must use that one instance of the Data class. Similarly if you have cached the records, you would presumably have only one class which controls / accesses the cache, and all clients access that one instance of the cache controller class.
(As an aside, I think Max at one time suggested that the lack of I/O exceptions in the signatures of the methods of the Data class could be argued as another reason for a cache ).
But you do have to make a decision about how you handle bookings. It is probably best to write each booking to disk as soon as it comes in. If you do not, you run the risk of loosing all bookings if the server crashes.
Regards, Andrew
 
Suresh Bansal
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree, its caching on server side, i confused it with caching on client side
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic