Ejemplo n.º 1
0
 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;
     }
 }
Ejemplo n.º 2
0
        //
        // 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);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 internal Cachie MergeWith(Cachie old)
 {
     Interlocked.Add(ref hits, old.Hits);
     return(this);
 }