zoukankan      html  css  js  c++  java
  • Cache文件缓存

    /// <summary>
    /// 文件缓存
    /// </summary>
    protected void SetFileCache()
    {
    //获取文件
    string filePath = Request.MapPath("File.txt");
    if(Cache["fileContent"]==null)
    {
    //文件缓存依赖项
    CacheDependency cDep = new CacheDependency(filePath);//如果文件内容修改后,让缓存失效
    //获取文件内容
    string fileContent = File.ReadAllText(filePath);
    Cache.Insert("fileContent", fileContent, cDep);
    Response.Write("数据来自文件");
    }
    else
    {
    Response.Write("数据来自缓存:" + Cache["fileContent"].ToString());
    }
    }

  • 相关阅读:
    蒟蒻的填坑计划
    现在的状态....
    date modify
    set source
    image source
    simple auth
    net
    bridge
    iptable
    namespace
  • 原文地址:https://www.cnblogs.com/jinjingBlog/p/9794581.html
Copyright © 2011-2022 走看看