Sunday, October 10, 2010

Caching..

Peri, Need a help.

I was interuppted when I genuienly started my day work at 5:45 PM. I swinged back and faced Nishant. He is a new joinee to my team and fresher. Lot of energy, and gulti. So you can imagine the IQ and english.

I dont want to disapporove his curiosity esply after blasting him twice since the afternoon - when I started reviewing his code. Eventhough I dont wnat to be a peoples person, I know how it is when someone disapproves you.

Yes, Nishant go on.

I have a question. Is it better to call Hashmap or a function().

Now I could relate the question. Since afternoon I was explaining how to maintain a local-cache using a Map. And seems like he has a question in it or a better approach for a cache. Whenever some new person asks a question,dont stop them. It may be a great idea - new questions can bring in creative ideas. I truley beleieve in it and was trying hard to understand what he actully meant, with less worrying about what he actually asked.

After scratching me head for 2 seconds, what do you mean?

I mean calling a function can be better, know, in Java. Instead of calling a hashmap?

mm...still not getting the complete point what he is mumbling, what function you mean?

Any method.

Seeing my inablity to understand what he meants ( and probably scared of me scolding him, again, in the same day) Nishant started refining his statement.

Iam thinking, Java might take less time to call a method than a hashmap. Am thinking this may be faster than what we discussed.

mm..which method you are referring. It depends on the method. Can you show me the method you are referring, I slowly moved towards his laptop.

This is the method...

you mean the method where you get details from DB ?

Yes.

Now am getting the picture a bit. So you are saying since its a method call it will be faster than a hashmap?

Yes, I think so.

OH GOD I dont expect this crappy question...but keep it cool...dont take it on him....dont discourage..he will be upset..pls cool down.

But you are calling DB and fetching records right. That will actually be a time consuming task right? So the time taken for a function call will be including that, right?

And since DB calls are time consuming we are maintaining the cache, so that next time we will not call DB, right? So time taken for JVM to call a method may be faster, but what we need to worry here is how much time it takes to execute the method. which here would be more than the hashmap.

By now I hope he realised it was not a very-intelligent question and started smiling...

No comments: