示例#1
0
文件: Service.cs 项目: geffzhang/core
 internal void Cache(ActionContext ac)
 {
     if (!ac.InCache && ac.Public == true && Cachie.IsCacheable(ac.Status))
     {
         Cachie ca = new Cachie(ac.Status, ac.Content, ac.MaxAge, Environment.TickCount);
         cachies.AddOrUpdate(ac.Uri, ca, (k, old) => ca.MergeWith(old));
         ac.InCache = true;
     }
 }
示例#2
0
文件: Service.cs 项目: geffzhang/core
        //
        // CACHE

        internal void Clean()
        {
            while (!stop)
            {
                Thread.Sleep(1000 * 30); // 30 seconds

                int now = Environment.TickCount;

                // a single loop to clean up expired items
                using (var enm = cachies.GetEnumerator())
                {
                    while (enm.MoveNext())
                    {
                        Cachie ca = enm.Current.Value;
                        ca.TryClear(now);
                    }
                }
            }
        }
示例#3
0
文件: Cachie.cs 项目: geffzhang/core
 internal Cachie MergeWith(Cachie old)
 {
     Interlocked.Add(ref hits, old.Hits);
     return(this);
 }