格式化日期
<%#   string.Format("{0:yyyy-MM-dd}",DataBinder.Eval(Container.DataItem,"RoadGoodDate")   %>
<%#   DataBinder.Eval(Container.DataItem,"RoadGoodDate","{0:yyyy-MM-dd}")   %>

asp.net有页面缓存与API缓存及每请求缓存

页面缓存使用

<%@ OutputCache Duration="60" VaryByParam="*" %> 

API缓存
使用HttpRuntime.Cache.insert()    不返回值
HttpRuntime.Cache.Add()    返回cache引用,类型object
asp.net缓存、企业程序库缓存及格式化日期Call the Insert method, passing it an instance of the CacheDependency object 
asp.net缓存、企业程序库缓存及格式化日期
asp.net缓存、企业程序库缓存及格式化日期The following code example adds an item named CacheItem3 that 
is dependent on another item in the cache named CacheItem2:
asp.net缓存、企业程序库缓存及格式化日期
asp.net缓存、企业程序库缓存及格式化日期C#  Copy Code 


每请求缓存则意味着只将数据缓存为该请求的持续时间。
使用HttpContext.Items["key"]=value   
items是一个属性,返回Idictionary类型,idictionary每一项为System.Collections.DictionaryEntry实体。


企业程序库:

配置web.config文件:
 

<cachingConfiguration defaultCacheManager="Default Cache Manager">
    
<backingStores>
      
<add name="inMemory" 
    type
="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching" />
    
</backingStores>

    
<cacheManagers>
      
<add name="Default Cache Manager"     
    expirationPollFrequencyInSeconds
="60"
    maximumElementsInCacheBeforeScavenging
="1000" 
    numberToRemoveWhenScavenging
="10"
    backingStoreName
="inMemory" />
      
<add name="Loading Scenario Cache Manager" 
    expirationPollFrequencyInSeconds
="60" 
    maximumElementsInCacheBeforeScavenging
="1000" 
    numberToRemoveWhenScavenging
="10"
    backingStoreName
="inMemory" />
    
</cacheManagers>
  
</cachingConfiguration>


添加dll引用,添加名字空间using Microsoft.Practices.EnterpriseLibrary.Caching;
使用如下代码:

asp.net缓存、企业程序库缓存及格式化日期            CacheManager cm = CacheFactory.GetCacheManager();
asp.net缓存、企业程序库缓存及格式化日期            QKnowledge qk 
= new QKnowledge(1"hi,catch");
asp.net缓存、企业程序库缓存及格式化日期            cm.Add(
"qk1", qk);
asp.net缓存、企业程序库缓存及格式化日期            QKnowledge qk1 
= (QKnowledge)cm.GetData("qk1");
asp.net缓存、企业程序库缓存及格式化日期            cm.Remove(
"qk1");






优化程序速度
http://www.microsoft.com/china/msdn/library/webservices/asp.net/us0501ASPNETPerformance.mspx?mfr=true
      

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-22
  • 2021-09-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-16
  • 2021-05-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
相关资源
相似解决方案