• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cache database file

 
Patrick McDonogh
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my implementation i was thinking about caching the database file.
However in the assignment for URLyBirds 1.3.2 it says:

The company's IT department has a data file that contains the essential information for the company, but because the data must continue to be manipulated for reports using another custom-written application, the new system must reimplement the database code from scratch without altering the data file format.

The statement "data must continue to be manipulated for reports" in the assignment makes me think that i cannot cache the database as changes could be made by the other custom-written application.
 
Seb Mathe
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But isn't it say somewhere else something like "You may assume that at any moment, at most one program is accessing the database file"
 
Jeff Haynes
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my take on caching.

You may decide to NOT cache the database file. Which means every time you want to return a result set, or update a record in the database file, you must then access the file.

Which in the real world is not applicable because of a likely performance degradation, due to the potential number of times one would have to re-read the file. However no where in the assignment does it say that Performance is something you MUST consider when designing your approach.

Though I would suggest that if you take this approach make it clear in your choices.txt file, and reference your reasons for doing so.

The second option is a bit more real world in that you do implement cacheing. IMHO this is a bit more complicated but not so much that you would risk failing the assignment due to an overwhelming amount of extra code that could lead to errors.

I have chosen the second approach and have documented why in my choices.txt file. I take the approach of maintaining a date-time for the last time the data file was updated. I keep this date in my Data class as a private member variable, and update it on initial read as well as every time I write to the file. In my case I write to the file every time an update occurs to any record. When a read action occurs, say a search, I check to see if the date on the file has changed, and if it has, rebuild my internal data array.

I don't worry so much about File Access Collision because as the directions say only one app will be accessing the file at any given time.

Hope that helps.


 
Patrick McDonogh
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a quick thanks for your responses, as always its a great help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic