zoukankan      html  css  js  c++  java
  • 很高兴今天学了点新东西,关于Cache

    代码
    private System.Web.Caching.CacheItemRemovedCallback cacheCallBack;//先声明一个删除缓存的委托
    cacheCallBack = new System.Web.Caching.CacheItemRemovedCallback(CacheDelete);
    //将委托和函数CacheDelete绑定

      CacheDelete(cacheKey, count, CacheItemRemovedReason.Underused);
    //手动调用删除函数cacheCallBack,Underused的表示这是我手动调用函数删除

       
    Cache.Insert(cacheKey, count.ToString(), 
    null, DateTime.Now.AddSeconds(5), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Low, cacheCallBack);
    //五分钟过期自动删除缓存与调用cacheCallBack


        
    private void CacheDelete(string cacheKey, object value, System.Web.Caching.CacheItemRemovedReason e)
        {
            
    if ( e == System.Web.Caching.CacheItemRemovedReason.Expired || 
            e 
    == System.Web.Caching.CacheItemRemovedReason.Underused
          ){ }
        }

    ---------------------------------上面是c#的,又学了点基于JQ的CAHCE知识,就不开新文章了

     删除JQ的缓存  delete jQuery.cache[id][name];

     增加JQ的缓存  

     jQuery.cache[id] = {};

    jQuery.cache[id][name] = data;

    缓存的数据结构

    var cache= 
    {
        
    "id1"
        {
            
    "name""wsenmin",
            
    "phone""110"
        },
        
    "id2"
        {
            
    "name""fuMing",
            
    "age"19

        }
    };

    ---------------------------------------------------------------

    代码
    <html>
    <head runat="server">
        
    <title>Cache-缓存操作</title>  
        
    <script src="Scripts/jquery-1.3.2-vsdoc.js" type="text/javascript"></script>
        
    <script type="text/ecmascript">
            jQuery(document).ready(
    function() {
                jQuery.cache[
    'me'= {};
                jQuery.cache[
    'me']['name'= 'wsenmin';
                alert(jQuery.cache[
    'me']['name']);
                
    delete jQuery.cache['me']['name'];
                alert(jQuery.cache[
    'me']['name']);
            }); 
        
    </script>
    </head>
    <body>
        
    <form id="form1" runat="server">
        
    <div> 
        
    </div>
        
    </form>
    </body>
    </html>
  • 相关阅读:
    HTTP以及TCP协议
    分布式理论
    JAVA基础面试题
    JAVA基础面试题
    vue 中百度富文本初始化内容加载失败(编辑操作某列数据时,富文本中内容偶尔会为空)
    CodeMirror的使用方法
    JSON格式化,JSON.stringify()的用法
    promise与await的用法
    服务器端node.js
    数组扁平化
  • 原文地址:https://www.cnblogs.com/jacd/p/1765235.html
Copyright © 2011-2022 走看看