• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

(B&S)Number of Cache

 
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic