6 Answer(s)
-
0
public class MyAppService { public ICacheManager CacheManager { get; set; } public ICache Cache => CacheManager.GetCache("MyCache"); public void Set(int value) { Cache.Set("key", value); } }
See:
- <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Caching">https://aspnetboilerplate.com/Pages/Documents/Caching</a>
- MemoryCacheManager_Tests.cs
-
0
Thank you but how can read ??
-
0
Hi @Haytham,
This document also contains an example of Get <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Caching">https://aspnetboilerplate.com/Pages/Documents/Caching</a>.
_cacheManager .GetCache("MyCache") .Get(id.ToString(), () => GetFromDatabase(id))
GetFromDatabase method is runned if requested item is not in cache.
-
0
Is it possible to use the Cache to pass the data from Action to Action in the Controller or from Action to view instead of (TempData,ViewBag)in ASP.Net MVC ?? Or is it a bad choice
-
0
These serve different purposes: ViewBag (dynamic) and ViewData - valid for the current request. TempData - valid for a single redirect. Session - valid for a login session. Cache - valid for 60 minutes (sliding expiration) while your application runs (singleton) and shared globally (with other users).
-
0
Can use session ,tempdata , viewbag in Cloud /SAAS ??