You are correct :).

I would generally discount any overhead associated with a cache map lookup
(because thats the cache, which is meant to be the quick bit, and its only
going to happen the first time)

I brought it up specifically because of

PropertiesFactory.load
which has 3 places where it can return.

1.  returns null or the actual object
2.  returns the actual object
3.  returns null

Rgds

Ned


igor.vaynberg wrote:
> 
> a contract of the cache is that
> if cache.put(k,v); then v.equals(cache.get(k)) or v is null
> 
> so if you just created v and put it into cache, why also introduce the
> overhead of the lookup?
> 
> this style of code also has a single return point:
> 
> V v=cache.get(k);
> if (v==null) {
>   v=new V();
>   cache.put(k,v);
> }
> return v;
> 
> its just coding preference, we seem to like the example above more.
> 
> -igor
> 

-- 
View this message in context: 
http://www.nabble.com/Ideas-on-cache-tp15452545p15469853.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.

Reply via email to