How to temporarily store data in DotnetNuke 7?

I am new to DotnetNuke. Feel free to suggest me the correct terminology. I am working on DotnetNuke 7. I am using C #. I have a table with 30 string fields and can have a maximum of 50 records. I am currently managing it using a database.

I think this is not so much data, and I should store it in local storage (if any), which can be faster than getting data from the database.

Can someone suggest me if there is any local repository (temporary) and his life in DotnetNuke?

Also, please tell me about my idea of ​​switching local storage as well as database.

+4
source share
1 answer

You can use the built-in functionality of the DNN cache.

using DotNetNuke.Common.Utilities;

public bool cacheExists(string key)
{
    return DataCache.GetCache(key) != null;
}

public void setCache<T>(T value, string key)
{
    DataCache.SetCache(key, value);
}

public T getCache<T>(string key)
{
    return (T)DataCache.GetCache(key);
}

Using:

string myString = "test";
Book myBook = new Book();

setCache(myString, "A");
setCache(myBook, "B");

string myStringFromCache = getCache<string>("A");
Book myBookFromCache = getCache<Book>("B");
+1
source

Source: https://habr.com/ru/post/1660749/


All Articles