• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

(B&S)Number of Cache

 
Saheed Adepoju
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I am still doing my analysis, so i havent written code yet!I have a question on how many cache we can have. I have an idea and here it goes:
I figured i would have 4 cache:
BookedRecords Cache(An ArrayList) This would have an inventory of all booked records. All client wishing to book a record that isnt booked will check here first, if the record number exists in the arraylist, then it doesnt even bother trying to book a record.
DeletedRecords Cache(An arrayList): This would have an inventory of all the deleted records. All client wishing to lock also check here to ensure that the record aint deleted.
LiveRecords(An ArrayList): This would contain, all valid records that can be locked and that are not deleted.
LockedRecords(An arrayList): Even though I feel this might not be needed. I want to ask if the idea of declaring a cache for locked records is a good one cause I feel this should be handled while trying to lock.Basically the clients trying to lock also check this cache to find out if the record they are looking for is already locked.
Well that is that on this subject of cache! Have a nice day!
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Saheed,

Consider if you only have one collection instead of BookedRecords, DeletedRecords, and LiveRecords. Then, if your record is not in the cache it must be deleted. Simple.

As for the "Booked" / "Live" status - these are business functions and do not belong in the Data class. Your Data class should only be interested in providing records (of any type - you happen to be working with contractor data, but the Data class should work identically with a customer name database or a hotel database, or ...). It is only the business logic that "knows" whether a record is considered available or not.

Regards, Andrew
 
Saheed Adepoju
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perfectly understood! I agree with your opinions! I will make some modifications in my design and document them! Thanks Andrew, you and the rest of the guys that help out here are life savers!
 
Saheed Adepoju
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Andrew Monkhouse:
Hi Saheed,

Consider if you only have one collection instead of BookedRecords, DeletedRecords, and LiveRecords. Then, if your record is not in the cache it must be deleted. Simple.

As for the "Booked" / "Live" status - these are business functions and do not belong in the Data class. Your Data class should only be interested in providing records (of any type - you happen to be working with contractor data, but the Data class should work identically with a customer name database or a hotel database, or ...). It is only the business logic that "knows" whether a record is considered available or not.

Regards, Andrew


Ok good! What if i wanted to say use the create() method! How do i know which record to use! I would have to iterate thru the entire cache and then start looking for who is missing! If i had a cache for deletedrecords, i could simply access the record numbers and then jump to the particular record in the datafile and then reuse accordingly?If not how would i accomplish such a thing!I agree with you that the data.java shuld only concern itself with providing records! Thanks once again!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic