0

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?

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

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.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.