zoukankan      html  css  js  c++  java
  • System.Runtime.Caching;

    using System;
    using System.Collections.Generic;
    using System.Runtime.Caching;

    namespace EnterpriseLibraryCacheTest
    {
        
    public partial class WebForm1 : System.Web.UI.Page
        {
            
    protected void Page_Load(object sender, EventArgs e)
            {
                
    if (!IsPostBack)
                {
                    TestCache();
                }
            }

            
    protected void TestCache()
            {
                
    //set cache
                ObjectCache cache = MemoryCache.Default;

                
    //add cache
                List<string> listQuery = new List<string>
                {
                    
    "1","2"
                };
                CacheItemPolicy policy 
    = new CacheItemPolicy();
                policy.SlidingExpiration 
    = TimeSpan.FromMinutes(60);
                cache.Set(
    "myCache", listQuery, policy);

                
    //get cache
                List<string> listResult = (List<string>)cache["myCache"];
                
    foreach (string ary in listResult)
                {
                    Response.Write(ary);
                }
            }
        }


  • 相关阅读:
    Web Control 开发系列(三) 解析IPostBackEventHandler和WebForm的事件机制
    Web Control 开发系列(一) 页面的生命周期
    异步导入滚动条
    前端复习之HTML5
    前端复习之jQuery大全
    前端复习之JavaScript(ECMAScript5)
    前端复习之DOM、BOM
    前端复习之Ajax,忘完了
    前端复习之css
    前端基础复习之HTML
  • 原文地址:https://www.cnblogs.com/leeolevis/p/1749358.html
Copyright © 2011-2022 走看看