This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
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

URLyBird read() method

 
mark ken
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello:
I'm doing the URLyBird project. I'm going to use cache to load all data into memory.
But I found in the requirment Doc, It descriped the "read()" method in "DBMain" interface:
//******************************************************************//
// Reads a record from the file. Returns an array where each
// element is a record value.
public String [] read(int recNo) throws RecordNotFoundException;
//******************************************************************//
in this doc it require read record from file
Since I want to load all data to memory, do I still need implement this method as "read from file" .
Can I change "read()" method , make it read record from memory(cache),or I have to write two "read" method, one is read from file , another read from memory.

anyone can explain it! thank you very much!
 
dennis du
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am implementing the URLyBird too.

In my opinion,memory read data from datafile,
and read() get data from memory,so in fact, read()
read data from datafile too.

But I am not sure.
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are still reading the records from the datafile, even if you cache them. With a cache you are just reading the record before the method is actually called. I doubt you would run into trouble, as long as you document your decision to use a cache.

Many others in this forum have used cached records, and I have never heard of someone having issues with their read method. Now the issue of when to persist the data to the datafile has come up quite a few times, but that is another topic...
 
Inuka Vincit
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did the same thing.

My read method read from the cache, just make sure that your write and delete methods update the cache consistently with the file.
 
mark ken
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you guys! I got it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic