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>
  • 相关阅读:
    磊哥评测之数据库:腾讯云MongoDB vs自建
    一文看透浏览器架构
    必看!如何让你的LBS服务性能提升十倍!
    亿级曝光品牌视频的幕后设定
    Node 框架接入 ELK 实践总结
    大数据与 AI 生态中的开源技术总结
    数据库分片(Database Sharding)详解
    QQ音乐的动效歌词是如何实践的?
    Sql Server之旅——第九站 看公司这些DBA们设计的这些复合索引
    Sql Server之旅——第八站 复合索引和include索引到底有多大区别?
  • 原文地址:https://www.cnblogs.com/jacd/p/1765235.html
Copyright © 2011-2022 走看看