Reputation: 68912
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?
Upvotes: 0
Views: 98
Reputation: 2790
Here is an example of a custom IOC written by Ayende Rahien, it may be of some interest/help to you.
Upvotes: 1
Reputation: 5603
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.
Upvotes: 1