Lazy Load is too lazy!

Lazy Load is too lazy!

Old forum URL: forums.lhotka.net/forums/t/3069.aspx


Jordan posted on Thursday, June 21, 2007

We have a NameValueList that implements a lazy load in the Shared GetList Method. 

Class NameValueList

private mlist as NameValueList

public shared getlist as NameValueList

if mList is nothing

  return dataportal fetch.....

else

return mlist

end.

This worked the first time and went to the Dataportal.  The next time it used the mList. 

After stopping and starting the web project several times, I have noticed that mList is always loaded even for the first use during this run, and it has not hit the dataportal again.

I am not using any caching and the project is being restarted, so how and were is this data being persisted at?

I have read a couple things about caching and remember you guys making exceptions for shared methods, but did not see how this may be linked.

Thanks in advance!

Jordan

RockfordLhotka replied on Thursday, June 21, 2007

Shared fields exist for the lifetime of the AppDomain. When you say "stopped the web project" what do you mean? If you don't stop the ASP.NET worker process it probably doesn't drop the AppDomain...

josh.kodroff replied on Monday, June 25, 2007

You also may not be using the NameValueList for its intended purpose:  It's for things like lookup tables which change very rarely.  If you're querying a table whose contents change semi-regularly, you don't want to use the implementation as-is.

What you could do is add a member to store when the list was retrieved and put a timeout in your configuration file if it's a list that changes, say, every week.

If the list is changing all the time, then you're probably using the wrong class implementation as the caching may not be appropriate.

Copyright (c) Marimer LLC