views:

21

answers:

2

I am trying to write a simple IoC library, and i am going to use it in asp.net websites.
My Question is: Should i cache all the registered objects "i add this in Dictionary<Type, object>" and use the cached objects each request? ,or should i resolve them each time page loads or on a new request?

And does the exist tools such as unity has a built in caching?

+1  A: 

Existing tools allow you to specify the "lifetime" of an object. So you can give an object a "singleton" lifetime and only one will ever be created (the IOC container will cache it). Likewise, session lifetime, web request lifetime, etc. In each of these scenarios objects are appropriately cached.

Rob
i don't think it's crazy, if i am practicing and want to understand, else no one will create a new tool ever.thanks for letting me know that it will be cached in any IoC tool.
Amr ElGarhy
if you're practicing, you're right. Mea culpa, go for it.
Rob
+1  A: 

Here is an example of a custom IOC written by Ayende Rahien, it may be of some interest/help to you.

Matt