• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

So should lock synchronize on cache

 
Tony Collins
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've found the synchronization disscussions very interesting. And I think it might be best to synchronize on my cache for read and write.
But if I take this to it's logical extreme wouldn't I also have to synchronize on my cache in lockRecord as well, to avoid a dirty read ? As I need to check the record is actually in the cache, for the RecordNotFoundException.

Tony
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand you question based on the cache. Are you storing your data in cache when you first start up the client, and therefore the cache will not get updated ever from the server or data class?
I would not cache the data at all. It isn't necessary or a requirement. If you need to read the data always read directly form the data file.
As far as Dirty reads, if you read from the file when you ask for data, then you do not need to worry about dirty reads. And you really shouldn't care about dirty reads for this assignment. It is not a requirement.
It is possible that you do a search, get records back, another client books some data, and the original client still does not see the booking. That is fine for this assignment. You just need to reread the record right after lock and just before booking/modifying the record.
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic