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


  • 相关阅读:
    PG-日常管理
    PG-高可用(pgpool-Ⅱ)
    PG-基准测试
    PG-备份恢复
    PG-并发问题
    Go-常量
    Go-变量
    Oracle-11g升级PSU补丁
    Oracle-`sqlplus`工具使用技巧
    [CF1051F] The Shortest Statement
  • 原文地址:https://www.cnblogs.com/leeolevis/p/1749358.html
Copyright © 2020-2023  润新知