Does anyone know how to cache object on Web application start with structuremap 3? Is singleton method right approach ( o.For().Singleton().Use()), if yes is it cached?
Thanks
Does anyone know how to cache object on Web application start with structuremap 3? Is singleton method right approach ( o.For().Singleton().Use()), if yes is it cached?
Thanks
It depends on your needs. If your object never changes, singleton might be a good choice, but remember that the same object created at the start of your application will be used until the app is restarted. In most situations you want your cache objects to be refreshed once in a while to provide the current data. In such scenario you should use a custom structuremap lifecycle. Please take a look at http://notherdev.blogspot.com/2014/06/structuremap-time-expiring-objects-cache.html for a good example of possible implementation.