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


  • 相关阅读:
    (十一)设置关闭多核cpu的核
    (十)修改开发板主频
    (九)How to use the audio gadget driver
    (8)全志A64查看寄存器
    内存溢出问题配置
    百度数据库优化经验
    如何让sql运行的更快
    百度性能优化
    spring ioc原理
    JNDI
  • 原文地址:https://www.cnblogs.com/leeolevis/p/1749358.html
Copyright © 2011-2022 走看看