如何在DotnetNuke 7中临时存储数据? [英] How to store data temporarily in DotnetNuke 7?

查看:85
本文介绍了如何在DotnetNuke 7中临时存储数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是DotnetNuke的新手.随时建议我正确的术语. 我正在使用DotnetNuke7.我使用C#.我有一个包含30个字符串字段的表,它最多可以包含50条记录.目前,我正在使用数据库进行管理.

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

我认为数据不多,应该将其存储在本地存储(如果有)中,这比从数据库中获取数据要快.

I think it's not much data and I should store it in local storage(if any) which can be faster than get data from database.

有人可以建议我DotnetNuke中是否有本地存储(临时存储)以及它的寿命?

Can anybody suggest me if there is any local storage (temporary) and life of it in DotnetNuke?

也请向我建议我切换本地存储而不是数据库的想法.

Also please suggest me about my idea of switching over local storage rather database.

推荐答案

您可以使用内置的DNN缓存功能.

You could use the build-in DNN cache functionality.

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);
}

用法:

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

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

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

这篇关于如何在DotnetNuke 7中临时存储数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆