问题描述
你能否告诉我这是否是实现这一目标的正确方法[即利用DataCacheFactory],在一个页面的上下文中,任何有链接的人都可以访问的asp web应用程序[即不使用会话] -
$
这是我目前正在使用的[没有收到任何错误,但想确保我正确使用这个]
私有静态DataCacheFactory dataCacheFactory = new DataCacheFactory();
protected void Page_Load (对象发件人,EventArgs e)
{
if(IsPostBack)getResults();
}
protected void getResults()
{
DataCache dataCache = dataCacheFactory.GetDefaultCache();
//其余代码。 ..使用dataCache实例进行put和get ...
}
OR,我应该这样做 - 在方法之外声明dataCache obj -
私有静态DataCacheFactory dataCacheFactory = new DataCacheFactory( );
私有DataCache dataCache = null;
protected void Page_Load(object sender,EventArgs e)
{
if(IsPostBack)getResults();
}
protected void getResults( )
{
dataCache = dataCacheFactory.GetDefaultCache();
//其余代码...使用dataCache实例进行put和get ...
}
谢谢!
Hi, can you tell me if this would be the correct way of achieving this [i.e. utilizing DataCacheFactory], in the context of a one page, asp web application that anyone with a link can access [i.e. not using sessions] -
Here is what I am currently using [not getting any errors, but want to make sure I'm using this correctly]
private static DataCacheFactory dataCacheFactory = new DataCacheFactory();
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack) getResults();
}
protected void getResults()
{
DataCache dataCache = dataCacheFactory.GetDefaultCache();
// rest of code... use dataCache instance for put and get...
}
OR, should I do this like this -- declaring the dataCache obj outside the method -
private static DataCacheFactory dataCacheFactory = new DataCacheFactory();
private DataCache dataCache = null;
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack) getResults();
}
protected void getResults()
{
dataCache = dataCacheFactory.GetDefaultCache();
// rest of code... use dataCache instance for put and get...
}
Thanks!
这篇关于正确使用DataCacheFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!