I'm creating a web version of a desktop application that deals with financial information. The desktop application allows the user to load the financial scenario information, and then edit this information along with viewing reports based on calculations utilising this information. So for the web version there will always be a 'current financial scenario' selected, and this scenario is in JSON format. All editing (list views and detail views) is based on the contents of this JSON data. The calculation module takes as an input this JSON data, and then provides various calculated results, some of which are relatively resource-expensive to derive.
My question is then - how to maintain on a per-session (per logged-in-user) the JSON information, within the ASPNetZero infrastructure? I've looked at using a more general session approach (with SQL Server caching), but obviously I would prefer something that works within ASPNetZero, and also I couldn't work out how to get the cached information into the services in Application from the Web.MVC application.
I am very new to ASPNetZero, so I guess there is something I'm overlooking here, any help would be appreciated, thanks!
2 Answer(s)
-
0
Hi,
There's caching mechanism. You can use it to store your session object.
public class TestAppService : ApplicationService { private readonly ICacheManager _cacheManager; public TestAppService(ICacheManager cacheManager) { _cacheManager = cacheManager; } public Item GetItem(int id) { //Try to get from cache return _cacheManager .GetCache("MyCache") .Get(id.ToString(), () => GetFromDatabase(id)) as Item; } public Item GetFromDatabase(int id) { //... retrieve item from database } }
Check out <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Caching">https://aspnetboilerplate.com/Pages/Documents/Caching</a>
-
0
Thank you, that's exactly what I was looking for. :)