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: cache room records which read from the data file.

 
Ronggen Liu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

i want to cache the room records in a map when the application starting. in order to enhance the performance. so when the use want to find a room, just get it from the map; and when the use updata,deleted or create a room, update it to the data file, and, update the map.

is it okay? is there any problem about lock here?

Thank you!
Ronggen
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Liu,

at this moment i'm not sure about caching my records or not, but my preference for now is not caching them.

in the instructions it's said that clear code is preferred above complex code even if the complex code is a little bit more efficient. and caching your records will add some extra code.
I haven't read something about it in my instructions, so this is extra code and will not give you extra points, can only get you a lower grade if something not ok with it

but regarding locking i guess something like this may appear:
- user A updates record
- code makes update in your cache --> get lock on cache and release after update
- code makes update in your file --> get lock on file (your program can continue because cache is already updated, other users will see the update even it's not written to database-file)
- update to file fails --> you have to undo previous change

if you do it the other way around, so first changing file and then changing cache (only if changing file is successfully ended): i guess you have to acquire lock on your cache and the file, because else something may be updated in your file, but not in your cache. so another user may see some "dirty" data.

just my thoughts concerning this approach...
 
Ronggen Liu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you,Roel,

it's really helpful for me.

-Ronggen
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Liu Ronggen:
Thank you,Roel,

it's really helpful for me.

-Ronggen


glad i could help even tough it was almost time to go
[ March 25, 2008: Message edited by: Roel De Nijs ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic